The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

posts_not_in by CATEGORY (4 posts)

  1. ngoodfellow
    Posted 3 years ago #

    I'm trying to figure this one out and having some issues:

    Trying to filter my posts by category so that a certain category is not displayed in the list
    this is in the Showcase Template for twentyeleven theme

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. ]

    // Display our recent posts, showing full content for the very latest, ignoring Aside posts.
    					$recent_args = array(
    						'order' => 'DESC',
    						'post__not_in' => get_category(15),
    						'tax_query' => array(
    								'taxonomy' => 'post_format',
    								'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),
    								'field' => 'slug',
    								'operator' => 'NOT IN',
    						'no_found_rows' => true,
    This is the code I think I need to change:
       'post__not_in' => get_category(15),

    This setting give me an error that it is not in an array, not sure how to fix that.

  2. Andrew Bartel
    Posted 3 years ago #

    Just put the number: 'post__not_in' => 15,

  3. ngoodfellow
    Posted 3 years ago #

    I resolved this issue with the following:

    'cat' => -$cat,

    This displayed posts that are NOT IN (negative before hand) the current category

    Seems to be working fine!

  4. Michael
    Forum Moderator
    Posted 3 years ago #

    there is also the 'category__not_in' parameter;

    'category__not_in' => array(15)


Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.