Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    WordPress Related Entries

    2nd August 2006

    This is the plugin you may find useful if you want to keep visitors to your blog for more than just one-post-reading-time. This plugin will provide to the user entries, which have some common/similar words in the post/page title.

    Installation is as always easy. Most probably you will want to put these ‘related entries’ into yours ‘sidebar.php’ or ‘right-sidebar.php’ (if you have one), and your code may well look like this (I assume that in ‘Plugins’->’Related Posts Options’ you set the pre/post tags to ‘<li>’ and ‘</li>’):

    <?php if ( is_single() || is_page() ) { ?>
    <li><h2>Related entries</h2></li>
    <?php related_posts(); ?>
    <?php } ?>

    The block of PHP code above the actual insert determines whether blog visitor is on the post page or blog page – this way ‘related entries’ will not be shown in listing pages. If you want, you can leave only is_single() in place, for related entries to appear only in posts, and not in pages.

    Finally, plugin home is:

    If you want your visitors, arriving from the wrong or just outdated links to find what they might be looking for, it will be a good idea to check Related posts for your 404. That plugin adds an extra function related_posts_404(), which you should put into your ’404.php’ template file. Now, when someone gets to your 404 page, they might as well get a list of close hits from your blog, and stay longer.


    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>