tags:

views:

113

answers:

2

I'm interested in modifying a template in a wordpress install to show related posts ... in my case, I think I'd be fine with just showing the latest 5 posts in the current post's category.

How would one do that without installing a plugin? I would rather modify the template in this instance

I've poked around on google trying to find and haven't been successful at finding the right API calls to make this happen.

A: 

There is a Related posts by category plugin, at http://wordpress.org/extend/plugins/related-posts-by-category/. Install it in WP admin and modify your theme. The following code generates a series of five li's containing links to the posts.

<?php
related_posts_by_category(
      array(
        'orderby' => 'post_date',
        'order' => 'desc',
        'limit' => 5,
        'echo' => true,
        'before' => '<li>',
        'inside' => '',
        'outside' => '',
        'after' => '</li>',
    //  'rel' => 'nofollow',
        'type' => 'post',
    //    'message' => 'no matches',
        'showthis' => true
      )
    );
?>
pompo
A: 

Like mentioned by the other posters you need an plugin to make this work. The reason ist, that there is no API in wordpress to get the related posts. What the plugins bsically do, is building a database out of all words in all postings and display the postings with the most common words.

See this question for some explanation on how stackoverflow is doing this. The book Programming Collective Intelligence has a good explanation on some of the more advanced approaches to the related posts problem.

mdorseif