• Sorry if this is easy for some, but I’m a bit lost. I have a sidebar with the following near the top to pull recent posts from a single category:

    <?php $my_catposts = new WP_Query('cat=5&showposts=8'); ?>
    <?php while($my_catposts->have_posts()) : $my_catposts->the_post(); ?>

    • ">
      <?php the_title(); ?>
    • <?php endwhile; ?>

      Then, further down the same sidebar, I want to put a list of categories, but the above code simple stops anything but Category 5. How do I reset the query to allow a list of categories further down? I tried the following, but not luck:

      <?php rewind_posts(); ?>
      <?php wp_list_cats('sort_column=name&optioncount=1&exclude=1,2,3,4,5,6'); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • how about trying query_posts, which resets the values for the queries or re-sets the query string that each loop runs, for each loop on the page (honestly, i can’t describe the inner workings, but this should work):

    <?php query_posts('cat=5&showposts=8'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_title(); ?>
    <?php endwhile; ?>

    then,

    <?php query_posts('cat=-1&orderby=title&showposts=1'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <?php the_title(); ?>
    <?php endwhile; ?>

    Note query_posts only only excludes one category at a time, but you can use workarounds

    See more:
    * http://infovore.org/archives/2005/04/12/multiple-loops/
    * http://codex.wordpress.org/Template_Tags/query_posts

    I’m having the same issue here.
    This code seems to work, but I don’t want the individual posts, I want to see the categories with the number of posts under those categories.

    I have 5 categories. 4 of them I want under Articles on the sidebar, and the other 1 I want under Interviews on the sidebar.

    Is there a way to use this loop for that? I tried the “wp_list_cats” and excluded certain categories, but the first exclusion trumps them all.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Twice re-ordering categories’ is closed to new replies.