PressTigers

Use Widget Title as a Hyperlink in WordPress

Widgets are counted as one of the main features of WordPress and plays an important role in WordPress Development. A widget is defined as a little section of a website which performs a specific task. We can add these widgets in different sidebars of a web page. WordPress has some built in widgets which are recent posts, calendar, tag cloud, search, navigation menu, etc.

Most of the displayed widgets have a common title field in which a user can write any text title or caption according to his/her need. In this title field, WordPress does not allow a user to use a Hyperlink in it by default. It will automatically remove all the HTML tags and only allows a user to put the text content in it.

Lets assume a situation that you have a widget in which the title should be a Hyperlink. Now in order to add a Hyperlink in the title field, you need to write a little bit of code. You can add the following chunk of code into your functions.php file (also you can use this code in any child theme):

Once you are done, go to your Widgets page from WordPress admin panel (Appearance -> Widgets). Add any widget which has a title field. After this, add the following line of code in your title. Make sure that the URL should be without quotes. The following screenshot will explain better:

text-field-hyperlink

This small chunk of code will make your widget title clickable. If this code does not suits your requirement then you can also use “Widget Title Links” plugin for this task.

User Comments

7 thoughts on “Use Widget Title as a Hyperlink in WordPress

    Susan says:

    What changes are needed to make the link open in a new tab?
    Thanks

    Mihir says:

    HI,

    The plugin does not work with latest wordpress. I gives an option add url but does not work.

    Also tried to add code in to function.php Does not help.

    Any idea?

      Hi Mihir,

      Thanks for pointing out the issue.

      We have revised the code, there were some extra spaces that caused the error. Please have a look at it.

      Let us know if the issue still persists.

      Regards,

      Ahmed Sarfraz | Associate Plugin Developer
      Email: support@presstigers.com

    Frankie says:

    Thanks a lot, worked perfectly.

    Susan says:

    It does make the title into a link, but also all the text in the box below the the widget title.

    John says:

    Thanks for this… It is working for me… _/\_

Leave a Reply

Your email address will not be published. Required fields are marked *

    Get in Touch