• Resolved Aaress

    (@aaress)


    Hi,

    I’m using a custom widget to display a listing of recent posts.

    However, I’d like to only show the posts from a particular category, offset by one, as that story will be featured in the slider above the widget.

    Here is my current query code (for this one I’d like to pick the category with the offset):

    <?php $recent = new WP_Query('showposts=' . $post_num . ' '); while($recent->have_posts()) : $recent->the_post();?>

    Also, I’d like to offset it by one here as well, but the category calls are already in place:

    <?php $recent = new WP_Query(array( 'category_name' => ' ' . $category2 . ' ', 'showposts' => '1'  )); while($recent->have_posts()) : $recent->the_post();?>

    Thanks for the help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Just using the real values instead of variables, this is what you need.

    $recent = new WP_Query('showposts=5&offset=1&cat=4');

    So that’s showing the posts 2-6 from category 4.

    Thread Starter Aaress

    (@aaress)

    Hi Steven,

    Thanks for the help! I used that and it worked great! I appreciate it!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change Loop to Show Recent Posts Only from 1 Category’ is closed to new replies.