$categories = get_categories( array( 'child_of' => 10 );
foreach ( $categories as $category ) {
$args = array(
'posts_per_page' => 5,
'offset' => 0,
'category' => category ,
'category_name' => '',
'orderby' => 'date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'author' => '',
'post_status' => 'publish',
'suppress_filters' => true
);
$posts_array = get_posts( $args );
foreach($posts_array as $post) {
// do anything you want with $post
}
}
Related Posts:
- How to get the number of posts in a selected category?
- Show related posts by category but ignore one category
- How to sort posts by last name (2nd word) on ONE category only?
- prevent showing posts of an specific category in admin posts section
- Add custom field to category of custom post type
- Can I hide a specific post from latest posts page?
- How to show post(excerpt) from specific category on wp page?
- New blog template to display only one category
- WordPress – Admin Manage Posts – Multiple Filters by Parent Category
- Custom Theme Want To Remove One Category From All Displays
- WordPress menu that shows all posts in a certain category like w3schools
- Divide Loop Into Days & Categories
- Different template for posts of all subcategories of category
- How do I render all posts of the same category in same layout?
- How to limit displayed posts on wordpress
- WordPress list posts from sub categories
- Mark menu item as current-menu-item for category
- How to set up multiple taxonomies for groups of posts
- How to display category from recent posts?
- Can I divide the pages into categories?
- Duplicate posts and change category
- Category Foreach keeps looping?
- post categories
- display a random post thumbnail from a random category
- Post page to display specific category
- Get Posts Under Custom Taxonomy
- Prevent additional top level categories but allow more children
- how to show single post in a custom template
- Is it possible to add/tick a category to a post when it is created?
- Excluding posts not working
- Hide posts belongs to few categories in homepage
- Limit the number of posts a category can have – newest post goes in, oldest one drops out, possible? plugin?
- Remove current category from post but display all others
- store posts_id of category into a varable?
- How do I show posts from another wordpress installation?
- Latest posts by category — how to exclude current post?
- How do I include the category next to the title of a post?
- Relative number of post in category
- How to show a custom taxonomy in the theme?
- How to import nested categories from XML file?
- Display a mixed list of posts and media
- Migrate posts from category and sub-category via SQL
- Posts Missing in Dashboard after update
- Display post number by category
- How to get post with slug and exclude categories
- Retrieving posts by their date and category
- Are post, page and category IDs unique to each other?
- Static pages not working
- WordPress displays post on subcategory only
- Remove Featured Image from posts in specific category?
- Sidebar limiting to 10 posts?
- Categories Listing and Highlighting current category item
- Display hierarchical categories/sub-categories for a single post only
- Post in bulk based on category template
- Automatic duplicate/copy of post to a related page in WordPress
- Yoast breadcrumb URL shows category instead of the page
- Author post count in category
- Query prints posts without specific categories
- Foreach issue in get_posts function
- Why do I have categories with duplicate slugs?
- Automatic Table of contents with categories and posts
- More Than 50K Categories and WordPress Admin Panel Stop Showing Categories and Posts
- Re-order Category Meta-data
- post categories – how to show only categories with a specific parent id
- Creating a “category” of featured posts
- Is it possible to remove actual post pages in wordpress but keep them in categories
- How do I make it so that new posts within a certain category go into a certain page?
- Need help with hiding an image within a post in a category
- WordPress not showing recent posts
- How to get post count including nested categories
- List Authors For Current Category
- How to filter out post from a category not its subcategory in wordpress dashboard
- List posts of assigned categories in list of all categories on single.php
- How can I display a specific number of post in a category via a url
- how to chang preview of list of articles of one category?
- Post of a specific category – not to be seen in paging previous/next post
- How to show main category related to that post
- Display selected category on post page
- Assign specific ads to specific categories/posts
- find posts with exactly 3/4 categories
- Sort post by category using HTML Select tag
- Make assigning post to a specific category equivalent to assigning it to all categories
- How to use in_category?
- About number of posts in selected category
- Use radio buttons & checkboxes for post categories
- Displaying only posts from a certain category on my custom page template
- Add default content to post (for specific category)
- List posts that are in the same category as the current post title
- Category page shows “No Posts” but I do have two assigned
- Exclude a ‘portfolio’ custom category?
- Multiple blog “feeds” in a single blog each with distinctly styled post pages
- How to get pagination working with “Pending” Posts
- ‘get_previous_post’ in same category returning (!empty) when no previous post in category exists
- Post’s arent displaying
- Show with echo if a post has two or more categories
- excerpt in template for specific page
- Only show posts belonging to multiple cateogries at same time
- Wrap posts from a category in HTML
- View post with specific category id and name which I selected in the backend (drop-down option)
- Filters do not work when there are multiple (one works)