WordPress.org

Ready to get started?Download WordPress

Forums

listing posts belonging to category in single post (2 posts)

  1. danaherlihey
    Member
    Posted 5 years ago #

    Greetings,

    I have set up my wordpress site so that each page displays posts from a specific category. Each page would have a left column with the post titles belonging to that category. However, I would like it, when you click on a post, for that menu to remain. So it must be present in the single post page.

    Rather than write a bunch of if statements and wp_query's i was wondering if anyone knew how I could make it so that other posts belonging to the same category as the single post were listed. There are over 5 categories, hence why I am looking for something simple. Preferably something that would work for both the page template and the single post template.

    thank you

  2. danaherlihey
    Member
    Posted 5 years ago #

    this is currently what i have

    <?php
    foreach((get_the_category()) as $category) {
        echo $category->cat_ID . ' '; 
    
    } 
    
    ?>
    <?php query_posts('cat=$category->cat_ID');
      						while (have_posts()) : the_post();
     						 ?>
    
    				<a class="title" href="<?php the_permalink() ?>" rel="bookmark" title="Read the feature article: <?php the_title(); ?>"><?php the_title(); ?></a>
    			 <?php endwhile; ?>

    however, it is listing all post titles and in the single post view it is also aggregating all posts from the blog.

    lil help?

Topic Closed

This topic has been closed to new replies.

About this Topic