• Resolved Swennet

    (@swennet)


    How do I make a list of all posts, but exclude the posts of 2 categories?

    I need to make a ‘lastest episodes’ list but I want to exclude the ‘Uncategorized’ and ‘News & Updates’ category.

    Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Need a little more detail. Is ‘latest episodes’ just newest posts, or a category?

    If it is latest posts, this should work:

    <?php
    $excluded_cats = array( 44, 55 );  // ids to exclude
    $args = array(
       'caller_get_posts' => 1,  // Don't show stickies at top
       'posts_per_page' => 5,    // The number of latest to show
       'category__not_in' => $excluded_cats,
    );
    query_posts($args);
    Thread Starter Swennet

    (@swennet)

    @vtxyzzy

    ‘Latest Episodes’ is every post I make which is not located in the ‘uncategorized’ and the ‘News & Updates’ category. So they’re posts from several different categories.

    Also I need to list only the post name with an URL to the post as I will use it in a sidebar widget.

    The code I showed should select the 5 newest posts which are not in categories 44 or 55. You can follow that code with ‘standard’ loop code to display whatever you want from those posts.

    Do you need a more specific example on the loop?

    Thread Starter Swennet

    (@swennet)

    I got it to work, thanks for helping.

    You are welcome!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘List all posts except 2 categories, how?’ is closed to new replies.