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:
- Can I hide a specific post from latest posts page?
- How to call posts under a specific category on static front page?
- Show posts on front page only
- Category posts show on local install, they do not show on live server
- Category and Posts in front page
- How to show related posts by category
- Including categories in search results
- Count how many posts in category
- Custom Single Post By Category
- Convert custom fields to post categories
- Query posts from current year
- Show One Category on Post
- Do I use custom post type or something else?
- How do I get the slug of a custom taxonomy category of a post?
- What Defines What Category A Post Picks (if in multiple)
- Featured Posts for Category Pages
- Limit function to specific post category
- Show all post titles
- Add Category name to Post Title (h1)
- Posts are not showing up on particular category
- How to display related posts by subcategory and not parent category
- Category Template: Need to display different content on first page of archives
- How to display WordPress archive into three columns [closed]
- Display post category in foreach loop with category link
- Get mixed category random posts
- Extracting post categories
- How to limit posts by category
- Get user categories with most posts in it
- How to list recent posts in a wp nav menu?
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- How to display two blog categories as separate sections on one page?
- why does wordpress ignore the post args?
- How can you display all sibling categories to a post?
- get posts from Custom Post Type & Category
- Category page when using static front page
- How to enable custom Shortcodes in Post Category Description? [duplicate]
- Sort by last word in title
- Give posts a particular template based on the assigned category
- Get latest post from categories
- Post-Archive like a page in a specific subdirectory
- How to display only one category in a custom post type?
- Get only X number of categories
- inserting a category into post
- Getting posts from some categories plus some individual posts
- Change layout of post depending on category
- Use Post as Front Page
- latest post showing up twice on posts page
- wp_list_categories() Exclude All Categories Except One
- Highlighting Current Category in the Archive and Feeds page
- Get current taxonomy and display query accordingly
- Geting error in post and category [closed]
- Different post views for different category views
- “Home” Page now only displaying the single latest post
- Possible?! A contextually titled back link
- Allow / show post comments in category pages
- Display a specific category in a focused area of my site
- How to select a category automatically based on a word in WordPress post title?
- Display default matabox of posts(add category) wordpress
- How display related post only in Default category on single
- How to get tags when using publish_post
- How to add class to specific navbar item when post parent category is in specific category
- How do you change the permalink for posts for a single category?
- Posts are not displaying on their category and tag page
- how to create a category with wp_insert_post and post_category
- How to 301 redirect from url with post id to permalink with post name (slug)?
- Create/Set Category as Title of Post
- Exclude posts in a category on one page but show those posts on a different page
- How to add a block to a category page?
- Excluding category from post navigation in WordPress?
- Post not showing in the front page
- show image gallery in archives or category page
- Page with Category Returning 1
- Post Category link is same with Page link
- Get 5 most recent categories
- Show custom post category for single post
- Get a list of categories that are related to posts
- Querying posts from current category, using a variable as array argument
- Precedence of page permalinks over woocommerce product category links?
- Need help writing loop to display posts by categories in separate divs
- Add category selection to function request
- Query post category & remove any post id
- Multiple Post Repeat for Related Post Loop by Category
- Show Post number of specific Category
- Add category attribute to custom recent post shortcode
- Latest Posts not in the right order
- how to show posts on different pages if number of post per page is one
- How to Include a common category in a custom Category Search
- How to display only one post on first category page and rest on next pages?
- Is possible to create a custom link that creates a post that’s already categorized?
- Is it possible to have different header style blog titles in different categories?
- Category pages vs single post pages
- How to display subcategory articles in the category view?
- How do we display a certain category type on a page while hiding all others?
- Viewing category won’t show up Custom post type posts
- Print out one of 2 post category [closed]
- How to get if category has posts?
- Show some texts in posts belonging to Specific category
- wordpress category Description not allowed tag
- How to sort posts alphabetically based on a specific parent category
- How to get a list of all posts and their categories?