You can use a tax query with include_children
set to false:
$query = new WP_Query( array(
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'your-category-slug',
'include_children' => false,
),
),
) );
Related Posts:
- Get posts from sites in Multisite?
- How To Modify The Loop in archives.php To Have 11 Posts Per Page and CSS Styling
- Using categories & “stickyness” together
- Does the ‘cat’ argument in query_posts fetch posts from subcategories as well as the given ID?
- List posts by category exclude current post
- Display only the latest post from multiple categories
- Select category in custom query
- Display one latest post from multiple categories
- Return category slug / title from category ID
- Exclude category from loop not working
- “NOT ONLY IN” taxonomy query operator?
- Post count for category and tag
- Checking for two categories in query_posts
- How to query post like normal search would do. within search.php page
- Query Posts Exclude Entire Category
- how to query posts and auto assign category if post title has keyword
- How do I call posts with a certain tag?
- Modify WordPress SQL Query to pull from within a category
- query order by category
- Get link which associated with a specific category and tag
- Order by category titles
- Have parent category contain only one post?
- List posts in alphabetical order
- Randomly load categories with latest post
- Set colors depending on category
- How do I query_posts in cat=1 AND not in cat=2
- List all posts in a category with query_post() function
- query_post order desc
- Exclude a category from a query that includes its parent category
- Show the latest post from child category?
- Pagination on category.php and tag.php not working
- Problem with different query loops (and “main loop”) on category template page!
- query_posts not reading correct categories
- Pagination for query_posts();
- Posts from a category on homepage with category archieves page default css
- function query_posts disabling current_page_menu class
- query_posts by category_name and custom taxonomy
- wordpress taxonomy query posts
- PHP dynamical conditional post display
- Posts of specific category on page and excluded from index.htm
- new WP_Query issues
- how can i hide category?
- Displaying links to all posts of the same category on the post page
- Post not found when filtered by category ID
- Exclude categories from postquery
- Sort posts alphabetically by category/custom taxonomy, insert divider between different types
- Show posts from category specified using a custom field
- query_post problem
- Add class to current post in query_post
- Different post slug based on archive
- Pagination does not work with query_posts()
- Assign a class to first element in category in loop
- How to display products with multiple conditions, product_id and category_id
- Displaying posts by year
- Paginate WordPress Category Pages
- How to have a category not show up in query post with page panigation?
- Query pages by category
- Showing one post from each category, paged?
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Display list of Sub-Categories and the posts they contain, within one main Category
- Create subdomains for tags and categories
- How to get this only in small letters (lowercase)? [closed]
- How to totally get rid of Category in my blog?
- Is there a function to cause empty categories not to show in menus?
- Category Specific Archive
- How to get the number of child categories a specific parent category has?
- Removing category base form links messes up the parent-child behavior
- How to list only child categories?
- Cannot add / edit categories to a post anymore
- List archived posts by subcategory
- What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?
- How to get the id from the custom category?
- Unwanted Duplicate Product Categories in WooCommerce
- WP didn’t redirect to canonical category URL
- WP admin broken. Not saving catgories or adding categories to menu
- get_terms function not returning anything
- Getting All Post From Specific category in wpdb
- Single.php Category Post Count
- Jigoshop – only displaying 10 products
- Show the amount of posts in a tag in a specific category has
- Conditional category & tag statement
- How to remove the category from post slug
- How to display posts from specific category using get_option function?
- How to show only child categories using the_category();
- Why in the e-mail notification about a new post published, the category of the post is always: Uncategorized
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- Identify a single category and output some code on an archive page
- in post content shortcode works, but hardcoded in same page template doesn’t?
- front end add category to new post
- List posts from a category and embed them into a page
- Get category of a taxonomy for a queries object in a loop
- ACF Gallery with Media Categories – how do display categories and sort
- Show parent category if there is no subcategory
- Add category links?
- Add html word before category
- Category that can hold only specific number of post
- How to add the sidebar in all category page
- Print child category slug nicename