WordPress Plugins for Internal Linking

Part of your strategy in building a successful blog or website ought to include building a strong internal linking structure. This accomplishes several goals, such as increasing your search engine ranking by directing them to spider and rank your pages better, as well as showing more related content to your visitors which encourages them to stay a bit longer.

But the process of internal linking can sometimes be a pain. WordPress doesn’t have a quick dropdown to see a list of posts while you’re editing or creating a new post. So not only do you have to scour your website for related articles, but you need to actually build the links as you would do for any external site that you link to. It’s not a monumental task for any one link, but the process becomes extremely tedious when done even three or four times per blog post.

Shouldn’t there be an easier way? After all, you’re dealing with your own website here, where everything should be integrated and play nice together. Fortunately, when you’re dealing with WordPress, there’s usually a way to do just about whatever you want to do.

The first plugin you need to install is some sort of related posts plugin. This is probably the easiest way to link to other content on your blog. I’ve been using Contextual Related Posts on a few of my blogs lately, but there are many plugins that will do the job just fine.

But you’ll also often want to link to posts within the post that you’re writing, not just provide links at the bottom of the post. Surprisingly, I couldn’t find many plugins that make this process much easier. There are several plugins that allow you to link to other posts using a system of shortcodes, but it should really be easier than that. The only plugin that really does what I want is WP Site Links. But it needs a couple tweaks to work right.

When you first install it, the plugin is actually broken (and will break your whole website!). I’ve contacted the plugin author about this, so hopefully it will be fixed in an upcoming version. Fortunately, it’s an easy fix. Edit the “index.php” file of the plugin, and find the line below (around line 64):

$js = file_get_contents( $this->PLUGIN_DIR . '/WP Site Links/js/wp-site-links.js' );

Replace it with this line:

$js = file_get_contents( $this->PLUGIN_DIR . '/wp-site-links/js/wp-site-links.js' );

Then around line 70, replace this:

echo "<link href='{$this->PLUGIN_URL}/WP Site Links/style.css' type='text/css' rel='stylesheet' />";

With this:

echo "<link href='{$this->PLUGIN_URL}/wp-site-links/style.css' type='text/css' rel='stylesheet' />";

This tweak will make the plugin work, but you’ll want to make one more tweak in the index.php file if you use custom permalinks (and you should). Change this (starting around line 100):

// Grab post links
$sql = "
SELECT
`post_title`, `guid`
FROM
`{$this->db_model->posts}`
WHERE
`post_status` = 'publish'
ORDER BY `ID` DESC";
$page_links = $this->db_model->get_results( $sql );
echo "<ul class='wp_links_ul'>";
foreach( $page_links as $link )
{
$this->truncate( $link->post_title );
echo "
<li>
<a
title='". htmlentities($link->post_title, ENT_QUOTES)."'
onmouseup='return false;'
href='javascript:;'
class='{$link->guid}'>
". $this->truncate( $link->post_title ) ."</a>
</li>";
}

To this:

// Grab post links
$sql = "
SELECT
`post_title`, `guid`, `ID`
FROM
`{$this->db_model->posts}`
WHERE
`post_status` = 'publish'
ORDER BY `ID` DESC";
$page_links = $this->db_model->get_results( $sql );
echo "<ul class='wp_links_ul'>";
foreach( $page_links as $link )
{
$this->truncate( $link->post_title );
$slug = get_permalink($link->ID);
echo "
<li>
<a
title='". htmlentities($link->post_title, ENT_QUOTES)."'
onmouseup='return false;'
href='javascript:;'
class='{$slug}'>
". $this->truncate( $link->post_title ) ."</a>
</li>";
}

This will change the standard ugly links to the pretty permalinks you’ve set up in your WordPress settings.

Plugin customization done. Activate the plugin. Now when you’re writing a post, you’ll see a new box labeled “WP Site Links.” Drag this to the right of the editor for easy access (right above the “Categories” box). Highlight a few words in your post, then click on a post in the “WP Site Links” box to create a link to it. Simple.



Your Thoughts...


All content © Copyright 2012 by Designs by Chris.
Subscribe to RSS Feed – Posts or just Comments

Powered by WordPress
Designed by Graph Paper Press