On this page we have collected the most interesting and important information about Wordpress Query Posts Exclude Subcategories for you. Follow the links below and you will surely find answers to your questions.


categories - Exclude sub category posts from category ...

    https://wordpress.stackexchange.com/questions/136486/exclude-sub-category-posts-from-category-display
    $category = get_category (get_query_var('cat')); WP_Query( 'cat'=>$category, 'post_type' => 'post' ); However, when using category__in , you'll will not get results from the subcategory. $category = get_category (get_query_var('cat')); WP_Query( 'category__in'=>$category, 'post_type' => 'post' );

php - Exclude all sub categories from wp_query - Stack ...

    https://stackoverflow.com/questions/17993734/exclude-all-sub-categories-from-wp-query
    I would get the list of all sub categories with get_categories () and then build a 'cat' exclusion array based on the results. $args = array ('parent' => 98); $categories = get_categories ($args); $categoriesToExclude = array (); foreach ($categories as $category) { $categoriesToExclude [] = $category->cat_ID; } $args = array ( 'post_type' => 'sell_media_item', 'category__not_in' => $categoriesToExclude, …

WordPress - How to get posts in a category but exclude ...

    https://stackoverflow.com/questions/2792869/wordpress-how-to-get-posts-in-a-category-but-exclude-those-under-sub-categorie
    Looking at the Wordpress manual, there is the query_posts() function that does have a parameter that might work for you. Here is an example to pull only posts from category 129, but from none of the children categories of 129:

Exclude ALL posts from sub categories - WordPress ...

    https://wordpress.stackexchange.com/questions/64701/exclude-all-posts-from-sub-categories
    Exclude ALL posts from sub categories. Ask Question Asked 8 years, 4 months ago. Active 4 months ago. Viewed 2k times 3. 1. Need help with a wordpress-task. I want ALL the posts from sub categories to be excluded. Example: Cake Pie Apple; Pear; Banana ... Wordpress list posts from sub categories. 1.

categories - Query Posts Exclude Entire Category ...

    https://wordpress.stackexchange.com/questions/75311/query-posts-exclude-entire-category
    Read all the sub-categories of the parent, loop over the result to get the IDs of them all and then include all IDs in the query_posts() call. For example (not tested): $parent = get_cat_ID("Sports"); $kids = get_categories( array( 'parent' => $parent ) ); $a = array( $parent ); foreach ( $kids as $kid ) { $a[] = $kid->ID; } query_posts( "cat=-" . implode( ",", $a ) );

Display products from category but not ... - WordPress.org

    https://wordpress.org/support/topic/display-products-from-category-but-not-subcategory/
    [This thread is closed.] I am using a shortcode to display products from a certain category. But I need it to display only the first level products.…
    [CATITEMSBL#1]

In addition to information on Wordpress Query Posts Exclude Subcategories, on our site you can find a lot of interesting and useful information on related topics.

Related Information:

Popular Wordpress Info: