Customize the Link to WordPress within the Meta Widget Link List

Following my standards for external links, I also wanted the link to WordPress listed in the Meta widget link list to open a new browser tab or page.

Meta widget link list

Unfortunately, the widget itself does not offers the opportunity to modify the link to WordPress.

Digging into the code, I found the filter within wp-includes/widgets/class-wp-widget-meta.php, which gives the ability to customize this particular link

Change the Link

To change the link, I created another plugin. Here is the code:

<?php
/*
Plugin Name: Instance Factory Set WordPress Meta Link
Plugin URI: https://instance-factory.com/?p=2157
Description: Changes the link to WordPress within the Meta widget link list.
Author: Instance Factory, a project of the proccelerate GmbH
Author URI: https://proccelerate.de
Version: 1.0
*/

/* Disable direct access to this file */
if ( ! defined( 'ABSPATH' ) ) exit;
/* OK, start editing! Happy publishing */

/**
 * Customizes the link to WordPress within the Meta widget link list.
 *
 * Returns the changed link to WordPress.
 *
 * @param string $metalink The default link to WordPress.
 * @return string|void The changed link to WordPress.
 */
if (!function_exists('ifb_set_wordpress_meta_link')) :
    function ifb_set_wordpress_meta_link($metalink)
    {
        return '<li><a href="https://wordpress.org/" target="_blank" rel="noopener noreferrer" title="WordPress.org">WordPress.org</a></li>';
    }

    add_filter('widget_meta_poweredby', 'ifb_set_wordpress_meta_link');
endif;

/* That’s all, stop editing! Happy publishing */
?>

No magic at all: Just return the HTML code you want to be added to the list, register the filter, and that’s it.

Meta widget link list

To show the small icon indicating the external link, see Mark external Links using CSS and SVG.

Links

wpbeginner’s “ What, Why, and How-To’s of Creating a Site-Specific WordPress Plugin
Mark external Links using CSS and SVG

Leave a Comment

Please note that every comment requires the admin's approval before it will be published.

Any comment containing spam like "... great topic. Feel free to visit my web page ..." will be deleted. So please do not waste your and our time by leaving such comments.

We respect your privacy. When you leave a comment, your IP address will not be recorded by WordPress.