• Hi all,

    I’m new to WordPress and I’ve been wondering if this problem has a simple solution.

    Basically, my blog has a few categories, and one of them is Events. I want to be able to view posts from Events and view posts from everything else. Viewing Events only is easy enough because of the category view, but I’d like to know how I can create a new page that lists all posts that AREN’T in a category.

    Most tutorials I’ve seen online show me how to exclude a category from the main page, which isn’t what I want.

    Any help would be appreciated

Viewing 1 replies (of 1 total)
  • <?php
    $cat_id = 3; // category to exclude
    $args=array(
      'category__not_in' => array($cat_id),
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts not in category 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().
    ?>

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy
    Page Templates

Viewing 1 replies (of 1 total)
  • The topic ‘How to make a custom page that excludes a category of posts’ is closed to new replies.