Support » Fixing WordPress » How to create clickable link for widget title

  • [ Moderator note: moved to Fixing WordPress. Please do not use Developing With WordPress for these topics. ]

    Could someone please give me detailed instructions for adding links to the widgets titles on my front page?. I am using the Illdy theme. The Widget Title Links plugin does not work! I have tried some snippets and function.php modification codes, but none have worked. I also tried the Code Snippets and HTML Widget Text plugins, but could not figure out how to use them.
    I am an absolute novice with website creation and wordpress, and have no experience with coding. So I would appreciate a very “for dummies” type of detailed instruction.

Viewing 15 replies - 1 through 15 (of 24 total)
  • Hey @lakshmigopinathan,

    Have you tried this solution:http://www.wpbeginner.com/plugins/how-to-add-a-link-to-widget-titles-in-wordpress/?

    I hope this will help you to add the link on the widget title.

    Thanks,
    Chetan

    Thank you, Chentansatasiya. The solution you suggested requires the Widget Title Links plugin. As mentioned in my post, this plugin does not work. It is no longer updated or supported by wordpress.

    Hello @lakshmigopinathan,

    you can do something like this. Put below code to your functions.php file.

    
    add_filter( 'widget_title', 'accept_html_widget_title' );
    
    function accept_html_widget_title( $mytitle ) { 
    
      // The sequence of String Replacement is important!!
      
    	$mytitle = str_replace( '[link', '<a', $mytitle );
    	$mytitle = str_replace( '[/link]', '</a>', $mytitle );
        $mytitle = str_replace( ']', '>', $mytitle );
    	
    
    	return $mytitle;
    }
    

    After, then you can put the title something like this in widget title box.

    [link href = https://wordpress.org]My Widget Title[/link]

    I hope this will work for you.

    Thanks,
    Chetan

    Hello Chetan. I tried this and it didn’t work. This is what I did.

    I copied the code you sent, went to appearance—editor—Illdy: Stylesheet (style.css). And pasted the code below what was already there in the box. Then clicked on “update file”. After that I went to the widget title box and put in what you gave, replacing the https://wordpress.org with the link I wanted.
    But when I went to the front page, the widget title was just replaced with the link written as text.
    Am I doing something wrong?
    I can send you a snapshot, but am not sure how to insert it here.

    Hey @lakshmigopinathan,

    You don’t want to put my code into the style.css file. You have to put the below function into your current activated themes functions.php file.

    
    add_filter( 'widget_title', 'accept_html_widget_title' );
    
    function accept_html_widget_title( $mytitle ) { 
    
      // The sequence of String Replacement is important!!
      
    	$mytitle = str_replace( '[link', '<a', $mytitle );
    	$mytitle = str_replace( '[/link]', '</a>', $mytitle );
        $mytitle = str_replace( ']', '>', $mytitle );
    	
    
    	return $mytitle;
    }
    

    I hope you will clear now where to put my above code.

    Can you please tell me where I can find the functions.php file? Thank you!

    Hey @lakshmigopinathan,

    Could you please share your site name here? So, I can tell where are your functions.php file is located?

    Thanks,
    Chetan

    Hi Chetan, thank you for your patience! I found the functions.php file and put your code there. But, same problem. On the front page, the widget tile is displayed as the link in text form.

    My site is https://elegycommunications.com

    As you will see, I tried to link the “Writing” widget under services on the front page. I would like to link it to https://elegycommunications.com/writing/

    Hey @lakshmigopinathan,

    It’s located in your /wp-content/themes/illdy/functions.php

    Thanks,
    Chetan

    Hey @lakshmigopinathan,

    Try this one put below to your functions.php file:

    
    add_filter( 'widget_title', 'your_html_widget_title' );
    /**
     * html_widget_title function.
     * 
     * @access public
     * @param mixed $title
     * @return void
     */
     
    function your_html_widget_title( $title ) { //HTML tag opening/closing brackets
    	$title = str_replace( '[', '<', $title );
    	$title = str_replace( '[/', '</', $title );
    	$title = str_replace( ']', '>', $title );
    	return $title;
    }
    
    

    Put below to the widget title box.

    [a href="http://mylink.com"]Link to My Link[/a]

    Thanks,
    Chetan

    Hi Chetan, my site seems to have crashed and is no longer opening!

    Hey @lakshmigopinathan,

    Please revert all the changes which you made on the functions.php file.

    If you are doing changes using the backend then you can’t revert all the changes.

    For that, you need the FTP details and after then make all the changes revert.

    Thanks,
    Chetan

    I spoke to the host, and he told me that there are several error logs due to coding issues. My original problem has not been resolved and am now left with a bigger problem!

    I hope someone can help me!

    I am a novice as mentioned, and terms such as “backend” and “FTP” are jargon that I do not understand.

    Hey @lakshmigopinathan,

    You can give this post link URL https://wordpress.org/support/topic/how-to-create-clickable-link-for-widget-title/#post-9069969 to your hosting provider and ask them to remove the code which you added.

    Thanks,
    Chetan

Viewing 15 replies - 1 through 15 (of 24 total)
  • The topic ‘How to create clickable link for widget title’ is closed to new replies.