How to replace the WordPress link in sidebar

How to replace the WordPress link in sidebar

To replace the URL of WordPress site in the sidebar of your site you will need a hook below:

function replce_meta_wordpress_org( $string ){
  $string = sprintf( '<li><a href="%s" title="%s">%s</a></li>',
    esc_url( get_bloginfo ( 'url' ) ),
    esc_attr( get_bloginfo ( 'description' ) ),
  return $string;
add_filter( 'widget_meta_poweredby', 'replce_meta_wordpress_org' );

Put the code in the function.php file of your current theme. In our case the code take options of the blog and display link to Home page but you can change 3 strings in it and output your link:

  1. get_bloginfo('url') is URL of a desired link;
  2. get_bloginfo('description') is a description of the link, attribute ‘title’;
  3. get_bloginfo() is actually the anchor itself, name of the link.

Do not forget to use ‘escape functions’ like: esc_url(), esc_attr().

Also you can remain the variable $string empty then nothing is output at all.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.