Should I use absolute or relative links in my WordPress blog?

S

A discussion of why you may choose to use relative or absolute internal links in your WordPress blog website.

Pros for Using Absolute Links for Internal Links in your WordPress blog

Yoast SEO Internal Link Counter Woes

If you’re using Yoast SEO, the internal link checking only works on absolute links (2023). So, if you’d like to use this helpful too, then you’re forced to use absolute links.

Cons for Using Absolute Links for Internal Links in your WordPress blog

Comments show every pingback for your internal links, but that’s fixable

If you have pingbacks/trackbacks turned on, then by default, your blog will make absolute links of your own internal links a trackback that you must manually accept/delete/ignore. You have options if you use absolute internal links and want trackbacks turned on.

First, of course, there are plugins. You can install a plugin such as No Self Pings or add a snippet of PHP to your functions.php. I use the plugin Snippets to manage my functions.php snippets. I explain how to use the Snippets plugin on your WordPress site in this post.

This code snippet stops WordPress’s comments from tracking internal pings or trackbacks.

WordPress PHP Snippet for Removing Self Ping Backs

function no_self_ping( &$links ) {
    $home = get_option( 'home' );
    foreach ( $links as $l => $link )
        if ( 0 === strpos( $link, $home ) )
            unset($links[$l]);
}
 
add_action( 'pre_ping', 'no_self_ping' );

How to add PHP Remove Self Ping Backs to Snippet Plugin

What does an internal ping back in comments look like?

By default, if trackbacks or pings are active, then even internal linking will trigger a comment that requires an action.

Happy Blogging!

About the author

Kelly Barkhurst

Designer to Fullstack is my place to geek out and share tech solutions from my day-to-day as a graphic designer, programmer, and business owner (portfolio). I also write on Arts and Bricks, a parenting blog and decal shop that embraces my family’s love of Art and LEGO bricks!

Add comment

Recent Posts

Archives

Categories