• Hi,

    How do i exclude a category in this code?

    <?php wp_get_archives(‘type=postbypost&limit=5&format=custom&before=

    • &after=
    • ‘); ?>

      Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Can’t do that with wp_get_archives. Might consider looking at the something like:
    http://wordpress.org/extend/plugins/query-posts/

    Thread Starter Granit

    (@granit)

    OK thank for that.

    I had a look in the codex and that was all Greek to me,

    What i want is a simple code to get the 5 latest posted articles, and to exclude only one category.

    If i use query_posts('showposts=12&offset=3'); how to i write it out in order to replace the php wp_get_archives i posted above.

    Thanks

    <?php
        $args=array(
          'cat' => -3,
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => 5,
          'caller_get_posts'=> 1
          );
        $my_query = null;
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo 'List of 5 Posts but excluding category id 3';
          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;
        }
      wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter Granit

    (@granit)

    Thank you so very much MichaelH, that solved the problem for me and i can open my site again. 🙂

    Thread Starter Granit

    (@granit)

    I have bumped in to more problems with this one, i now need to exclude two categorys, i have tryed to add one more category behind the first in the code above but it did not work.

    How do i exclude two categorys with the code above?

    Thread Starter Granit

    (@granit)

    No one that knows hos to write the code to exclude two categorys`?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Exclude Category in wp_get_archives’ is closed to new replies.