Take a look at multiple loops for examples
And also look at the content.php file in the Twenty Fourteen theme
<?php
// The Query
$category_query = new WP_Query( 'category__in=11' );
// The Loop
if ( $category_query->have_posts() ) {
echo '<ul>';
while ( $category_query->have_posts() ) {
$category_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
} else {
}
/* Restore original Post Data */
wp_reset_postdata();
Don’t forget you can use pre_get_posts
to alter an existing loop and exclude categories from any loop.
Related Posts:
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Gutenberg editor add a custom category as wrapper for custom blocks
- Rewrite rule page url with category
- Different template for subcategories
- WP_Query not looking at child category
- Deleting default category in wordpress
- Most recent post from every category/taxonomy but sorted by date
- Category Archive, list subcategories of each post
- Disable pagination only for specific category
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Check if post belongs to any category
- How to add categories to products in woocommerce programatically? [closed]
- Is there a plugin that will completely remove the category system?
- How to sort categories by id in wordpress admin
- How to override Category rendering mechanism
- How to get only the last child of category slug?
- Remove Parent Category from Child Category URL
- Multisite – create a category in specific site
- How do you remove display of WooCommerce product category on single product page?
- Allow users to post to a certain category
- Show recent posts in menu?
- get_the_category and echo out link to child-most/deepest category
- Categorising posts/pages into years published
- Convert the default sub-category dashes to bullets or any other characters
- How to check category of of custom post type or not
- Set a them for all subset of category
- Display category description instead of “nothing found” page
- How to query post like normal search would do. within search.php page
- Link Attachment Image to Category
- Modify WordPress SQL Query to pull from within a category
- How can i insert term in a specific language of Polylang?
- How to retrieve more posts from a custom post type that are in the same category as the current post
- WordPress Get Posts from each category equally
- posts_nav_link(); picks up index.php instead of category.php as template
- Category name field strips HTML tags. How can I reverse this?
- Same base for category and post
- Get all media categories
- Custom taxonomy/category order
- Custom SQL Query: Get all posts with category id and a concated list of tags on each post
- Add tag parameter to category.php
- Check IF category_description exists
- Why custom taxomony not showing when create a post?
- wp_list_categories with show_count, except for specific categories
- Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)
- What Must to Display the “mysite.com/category” URL?
- List recent posts with link to first category
- How do I add a category to my post_type
- Link from navbar to categories
- WordPress showing wrong category name
- Add posts of a certain category to a page
- Show 10 Sub Categories Per Parent Category Page?
- Conditional category & tag statement
- How can I filter posts by tag on the fly
- Post Loop Category first show parent then child
- How to add a custom thumbnail size for a specific category?
- wp_nav_menu not appearing correctly on category page
- Post not found when filtered by category ID
- How to detect /category and /tag base pages?
- Custom menu with categories and tags
- How to Show or Hidden Categories on page in WordPress?
- Display all posts from selected category
- Is there any better/faster code than this ? It shows the categories that an author had ever posted in
- Show posts from a single category by default using wordpress.com
- category description not showing in my woocommerce
- Hide Some Categories in Post Editor
- Correct Hook/Filter to amend category choices on post edit page
- Only 10 of 233 categories selectable when adding a new post
- When creating category, it creates automatically tag, or, when creating tag, it creates automatically category in same name
- Should I select only the last child product category?
- List posts from a category and embed them into a page
- Default URL for category dropdown select option
- Media Library Categories
- Exclude category from WP_Query args not working
- WordPress pagination based on category
- How to echo Tags and Categories as plain text
- Make related posts display first in search result
- Display sub categories of a parent product in products – woocommerce [closed]
- Loop within category’s posts
- WordPress edit.php category filter to show only posts from direct category and not posts from it child category
- How can I just show portfolio items from 1 category on portfolio page?
- Custom category for posts via XMLRPC
- Children categories not shown in dashboard
- Loops in category description
- Archives and category of authors
- Detecting top parent category fails on home page
- not empty categories don’t show in menu [closed]
- Show parent-child relationship for categories in the wordpress admin
- How to assign different categories to pages in wordpress?
- how to ask if in two categorys inside if
- All post of child category not in top category
- How to add a tag above a category post that displays the category name in WordPress
- Woocommerce – Display product category of product in Orders page
- How to show video from wp option value?
- Changing Woocommerce categories programatically
- Add an Exclusive or featured tag line to article titles
- How to list out post category name and description in page
- Print child category slug nicename
- How to link ACF relationship field to the new Query block in Full Site Editing
- Order Categories by Character Count
- Restricted category in Woocommerce [closed]