• Resolved idesign123

    (@idesign123)


    I’m still pretty new to WordPress and am trying to figure out how to show posts just from one category.

    I did find some code snippets, but am not sure how to apply to my particular chunk of code.

    Here is what I have right now…

    <?php if (have_posts()) : ?>
    <?php wp_reset_query(); ?>
    
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
     <?php query_posts("paged=$paged"); ?>

    How would I modify this so only posts from category #21 would show up?

    Thank you for your help 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi

    (@esmi)

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args= array(
    	'cat' => 21,
    	'paged' => $paged
    );
    query_posts($args);
    if (have_posts()) :
    ?>
    Thread Starter idesign123

    (@idesign123)

    Yes, that did the trick!
    Thank you so much 😀

    Thread Starter idesign123

    (@idesign123)

    Oops, looks like I need one more minor tweak…

    Can this be adjusted so instead of showing posts from category 21, it shows posts from all categories EXCEPT categories #1 & 5?

    After that tweak, it should work perfectly.

    [No bumping, please.]

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Only posts from one Category’ is closed to new replies.