• Resolved ads1018

    (@ads1018)


    Is there any way to display the archives in the sidebar according to category? I use this in my sidebar which lists the posts chronilogically:
    <?php wp_get_archives('type=postbypost') ?>

    But, it lists all my posts. I only want it to list my posts from a certain category.

    Any ideas on how to go about this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ads1018

    (@ads1018)

    Problem solved. I had to install a plugin called ‘Archives for a Category’. This let me add the ‘cat=8’ parameter to the wp_get_archvies tag which for some reason doesn’t normally accept it. I really think wordpress should include it in the codex so people don’t have to bother with a plugin.

    Or this in your sidebar.php or php-code widget:

    <?php
        $args=array(
          'showposts'=>5,
          'category__in' => array(7,9),
          'caller_get_posts'=>1
        );
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo '5 recent Posts from category 7 or 9';
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
          endwhile;
        } //if ($my_query)
      wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_get_archives tag’ is closed to new replies.