Display posts that have this category (not children of that category), using category id:
$cat_post = new WP_Query( 'category__in=4' ); // you will replace the 4 with your category ID
if( $cat_post->have_posts()){
while( $cat_post->have_posts()):
$cat_post->the_post();
// NOW RIGHT THE CODE AS PER YOUR DESIGN
endwhile;
}
Related Posts:
- Display posts from the same category using next/previous post link
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- WordPress Multiple Category Search
- Delete a specific category when deleting a user
- Show Previous/Next Posts navigation only inside the same category
- 404 error on subcategory pages
- Add line breaks in Category description via enter
- Filtering WordPress Contents based on URL
- Excluding a category from next and previous post links
- Rewrite category slug
- View category in the preview of Theme Customizer
- Display only the latest post from multiple categories
- Get terms that are associated with products from current category
- Mass/Bulk assign categories to posts
- How to list categories and subcategories in JSON format?
- how do I filter single_cat_title to remove all instances of a particlular word
- Duplicate Category and Page URL loads Category instead of the Page
- wp_nav_menu not highlighting the current category when viewing a single post
- WordPress order categories by ID
- ACF: Display category name using taxonomy field
- query order by category
- Shortcodes not working in category or tag description
- Post in multiple categories
- Mod_Rewrite to show only last subcategory in URL
- wp_dropdown_categories() scripts working erratically on sidebar
- Access current post parent and sub category
- Give a page priority over a category that has the same name?
- How to exclude the last post from a category(featured for example) from the main loop?
- How to rewrite the post URL according to the category?
- wp e-commerce group product by category [closed]
- Sticky post for each category on category pages [duplicate]
- ajax for filtering posts by category in wordpress loops
- get parent category only
- Question on using custom structures for categories
- How can I tell what category I’m in– in the header?
- new WP_Query all post in a category inside the loop
- How to add orderby parameter for sorting on category.php
- delete category name in the pages
- Category tags with comma’s
- Filter posts by categories ajax is showing nothing
- How to display child categories of all parent category within a singe loop?
- How can I add a class to displays a category?
- How to show only the name of one category above each posts in frontpage?
- WP_Query – using category__and when one of the categories is 0
- Multiple categories for one menu item?
- Tags Instead of Category
- Exclude categories from homepage not longer working
- Remove category link
- javascripts files not linking to my category slugs?
- Related posts widget – category
- Editing Loop So It Targets Specific Tags?
- Pretty URLs with Categories and Tags
- Select posts that match multiple category names, must match all categories listed
- How can i display category title over thumbnail?
- Header Link function not working. Problem with bloginfo()
- WordPress category filters as subcategories
- Sort posts alphabetically by category/custom taxonomy, insert divider between different types
- Need help with major category and permalink re-organization
- Include home page template in specific category template
- How to use category slug with a regular page
- Display all categories but only if they have posts in them that have a specific tag assigned
- Show audio player only in specific post type category
- Modifying category order
- display current portfolio categories from a specific parent
- Regarding Tags And Categories
- selecting categories that have products with tag/category
- Please tell how to stop the category from showing up on posts
- how to get only grandchild category from a child category
- Remove “category” from permalink with add_rewrite_rule
- Next and previous links category infinite loop
- How to get WooCommerce Product Categories and its children’s children?
- How to hook into creating a category?
- Media Library Category Exclude Tree
- show only terms from parent category
- show posts in archive page based on selected catagory
- How to display child-category PAGES on a category page
- How get all media from a posts category by db?
- Cant get unique_array() work on get_the_category() foreach loop
- How to display total views of all posts of one category?
- Get the categorie name of Event Organiser plugin [closed]
- get_categories returns top-level categories instead of child categories
- Show posts from all categories
- Display the category name of a post that is in two different categories
- how to Specifies an author / editor to edit one category only?
- Link to a latest news item with correct url
- Post in multiple categories do not include in previous / next post if one category in excluded
- exclude parents from the_terms
- How can i display in a archive page a number of post i want
- Problems with explode [closed]
- How to create category page
- Exclude Category From Home Page, Display Posts on It’s Own Page?
- Category Template – to be editable from the backend?
- How to get child category list post in one template?
- i want to add pagination list of categories
- Woocommerce custom taxonomy order
- Update wordpress menu with woocommerce products
- How do you get parent and grandparent categories [duplicate]
- AZ Directory posts directory index
- WordPress how to remove parent slug from category URLs