WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Get Posts: Category

[Resolved] Get Posts: Category

  • Hey guys,
    When looking at a post, I need it to bring up a list of only the posts in its category. Currently it lists all posts regardless of category.

    I’ve figured out how to make it static
    $postslist = get_posts(‘category_name=news’);

    I need it to be dynamic.

    Here is my relevant code

    <ul>
      <?php
        $postslist = get_posts();
        foreach ($postslist as $post) :
        setup_postdata($post);
      ?> 
    
    <li>
       <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </li>
    <?php endforeach; ?>
    </ul>

    [moderated–bump removed. Please refrain from bumping as per Forum Rules]

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] Get Posts: Category’ is closed to new replies.
Skip to toolbar