/* exclude sons */
$_categories = get_categories(array( 'child_of' => 16));
$exclude="";
foreach($_categories as $category){
$_exclude .= '-'.$category->term_id.',';
}
$_exclude = substr($_exclude,0,-1);
$_cats = $cat.','.$_exclude;
query_posts(array( 'cat' => $_cats ));
while ( have_posts() ) : the_post();
......
endwhile;
Related Posts:
- Exclude posts that only have the ‘Uncategorized’ category [duplicate]
- Show related posts by category but ignore one category
- prevent showing posts of an specific category in admin posts section
- Exclude posts from featuring
- How can I remove posts of a certain category from homepage after a specified time period?
- List posts in a given category
- Get user categories with most posts in it
- Loop doesn’t exclude the specified category in home page
- Display posts of specific category term
- Migrate posts from category and sub-category via SQL
- WP_Query of Category Not Showing First Post
- Sidebar limiting to 10 posts?
- Query prints posts without specific categories
- show image gallery in archives or category page
- Page with Category Returning 1
- Get 5 most recent categories
- How can I display a specific number of post in a category via a url
- Order posts by separate menu order for different sub-categories
- Retrieve latest post by multiple categories with ID
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to Include a common category in a custom Category Search
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- List posts related to category on a div [closed]
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Filters do not work when there are multiple (one works)
- Should we trust the post globals?
- Querying post from a multisite network
- How to know if get_posts() failed?
- Post content being duplicated by the_content();
- How to add padding between posts
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Add custom field to category of custom post type
- Add few specific post ids to wp_query
- Can I hide a specific post from latest posts page?
- How to show post(excerpt) from specific category on wp page?
- WordPress – Admin Manage Posts – Multiple Filters by Parent Category
- Custom Theme Want To Remove One Category From All Displays
- WP_Query posts_per_page ignored
- Different template for posts of all subcategories of category
- wp_query ‘s’ parameter does not work with custom post type
- Mark menu item as current-menu-item for category
- How to set up multiple taxonomies for groups of posts
- WP Query – duplicated posts once including tags in search results
- How to display category from recent posts?
- Can I divide the pages into categories?
- Duplicate posts and change category
- recent posts for different categories
- Category Foreach keeps looping?
- Change post order random through out the entire WordPress
- Removing noindex posts from wp_query
- display a random post thumbnail from a random category
- Using wp_list_pages() after calling query_posts()
- Excluding posts not working
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- Why are my paginated posts always returning the same results?
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Query posts by Author and/or by Tag
- How do I show posts from another wordpress installation?
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- Display post number by category
- Exclude some posts from displaying in wp_query based on some condition
- How to get post with slug and exclude categories
- Static pages not working
- WordPress displays post on subcategory only
- Categories Listing and Highlighting current category item
- Display hierarchical categories/sub-categories for a single post only
- WP_Query get posts in custom database table [duplicate]
- WP query taxonomy optimization
- Author post count in category
- Displaying all posts from other sites on the network on one site
- Multisite how to display merged posts from two sites and sort by latest date?
- Why do I have categories with duplicate slugs?
- Using a meta_value or postdate to to query and orderby
- Exclude posts in home slider from sections
- Ajaxify Post Sort
- Get current user, change users post status to published
- Is it possible to remove actual post pages in wordpress but keep them in categories
- WordPress not showing recent posts
- How to get post count including nested categories
- Display WordPress Post By Date
- GUID to related post not in current language
- how to chang preview of list of articles of one category?
- Advanced Post Display/Pagination/Ordering
- Post of a specific category – not to be seen in paging previous/next post
- How to show main category related to that post
- Display selected category on post page
- Sort post by category using HTML Select tag
- How to use in_category?
- About number of posts in selected category
- WP_Query retrieve custom posts but not the post showing
- WP_Query based on a custom field result
- Category page shows “No Posts” but I do have two assigned
- Multiple blog “feeds” in a single blog each with distinctly styled post pages
- How to get pagination working with “Pending” Posts
- Post’s arent displaying
- Show with echo if a post has two or more categories
- How can I get on the same row two post of different categories?
- How add class the_content();?
- WP_Query post_tilte search in posts table