Support » Fixing WordPress » PHP link

  • There’s a social media widget on the footer of my template (, I want to change the “stay in touch” title to be a link that opens in a new window, I believe it’s the “$title” in the code, how do I do this, here is the code:

    function My_SocialNetworksWidget() {
    		$widget_ops = array('classname' => 'social_networks_widget', 'description' => __('Link to your social networks.'));
    		$this->WP_Widget('social_networks', __('My - Social Networks'), $widget_ops, $control_ops);
    	function widget( $args, $instance ) {
    		$title = apply_filters('widget_title', $instance['title']);
    		$networks['Twitter']['link'] = $instance['twitter'];
    		$networks['Facebook']['link'] = $instance['facebook'];
    		$networks['Tumblr']['link'] = $instance['tumblr'];
    		$networks['Pinterest']['link'] = $instance['pinterest'];
    		$networks['Twitter']['label'] = $instance['twitter_label'];
    		$networks['Facebook']['label'] = $instance['facebook_label'];
    		$networks['Tumblr']['label'] = $instance['tumblr_label'];
    		$networks['Pinterest']['label'] = $instance['pinterest_label'];
    		$display = $instance['display'];
    		echo $before_widget;
    		if ( $title )
        		echo $before_title . $title . $after_title;
Viewing 1 replies (of 1 total)
  • You can use the widget_title filter to modify the title. Add the code below to your child theme’s functions.php file. But be careful. If you cause an error, you must use ftp or a File Manager from your hosting service to correct it.

    // Filter to make Social Network Widget's title a link
    function mam_widget_title_filter($title) {
       $social_network_title = 'Test widget';  // Put your title here
       $url = 'http://localhost/test/articles/cities/';  // Put your URL here
       $new_title = $title;
       if ($title == $social_network_title) {
          $new_title = "<a href='$url'>$title</a>";
       return $new_title;
Viewing 1 replies (of 1 total)
  • The topic ‘PHP link’ is closed to new replies.