Support » Fixing WordPress » Display Other Posts From Current Category(ies)

  • I have a post that is in multiple categories and I’d like to show a listing of other posts that are in the related categories. The code below would be a starting point

    <?php query_posts('cat=1&showposts=5'); ?>
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
      <?php the_excerpt() ?>
      </li>
      <?php endwhile; endif; ?>

    I dont know…. something like this?

    <?php
     $categories = get_the_category($post->ID);
     query_posts('cat=$categories&showposts=5'); ?>
     <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
       </li>
      <?php endwhile; endif; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display Other Posts From Current Category(ies)’ is closed to new replies.