WordPress.org

Support

Support » How-To and Troubleshooting » Displaying Category Posts

Displaying Category Posts

  • I know this is simple, but when i am looking at single.php and an individual post, i want to display the most recent 5 posts in that category. But it obviously has to be dynamic so it knows which category your in, how do i do this?

    I have this and it doesn’t work; it displays posts from all categories:

    $cat = get_query_var(‘cat’);
    global $post;
    $myposts = get_posts(‘numberposts=5&offset=1&category=$cat’);

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Displaying Category Posts’ is closed to new replies.