$args = array(
'posts_per_page' => 5,
'cat' => 77 // 77 - id category
);
$query = new WP_Query( $args );
// loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
echo '<li>';
the_post_thumbnail();
echo '<a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
}
} else {
// posts not fount
echo 'posts not fount';
}
wp_reset_postdata();
Replace the category id (77) with the id of the category you need. You need to add this code to the template. In the place where you want to display the records (for example: index.php).
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
- Optimal way to redirect home page to category archive?
- How to Set an Individual Homepage for Each User?
- 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
- display woocommerce all category title on home page
- 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();
- function query_posts disabling current_page_menu class
- query_posts by category_name and custom taxonomy
- Shows only one Category in home page
- 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?
- Homepage custom recent news
- 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
- pagination 404 error, same slug home and categories
- Different post slug based on archive
- How can I exclude a particular category from my WordPress Page 1 and Page 2?
- 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
- Query post only from categories that have subcategories
- Display last postings of 5 categories on homepage
- Displaying posts by year
- Paginate WordPress Category Pages
- How do I get a single page navigation depending on the previous page?
- How to have a category not show up in query post with page panigation?
- Duplicate homepage to show posts from 1 category
- Query pages by category
- Showing one post from each category, paged?
- Country Ways Content Show
- How can I filter Query Loop to show only posts in current category?
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- Is There a Difference Between Taxonomies and Categories?
- List all subcategories from category
- How To Find Out WordPress Category Table in MYSQL?
- Add custom field to Category
- Get Category ID inside Category template
- Only one category per post
- WordPress Multisite – global categories
- Get the children of the parent category
- WP REST API: filter by category 1 AND category 2
- Keep featured content post in homepage with original order
- How To Get Parent Category Slug of Current Post
- Display All Products by Category with WooCommerce
- What is the difference between a “tag” and a “category”?
- Is there an easy way to make a meta box have the tabs like the Categories meta box has?
- How to check if I’m on the last page of posts?
- Display posts from the same category using next/previous post link
- How would I get a taxonomy/category list inside a Gutenberg block?
- Can I set a default featured image for a category?
- 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
- How to show all posts of the category in wordpress?
- Force category choice before creating new post?
- Gutenberg editor add a custom category as wrapper for custom blocks
- How to show related posts by category
- WooCommerce: List All Categories
- How to get category and archive title?
- Get category ID from category slug (not working)
- How do I remove “Uncategorized” from posts with more than 1 category?
- Get rid of WordPress category, tag and author archives?