here is a general structure how I would do it:
$categories = array(5,2,4,3,1); //manually enter the array of the category ids in the order how you want them to appear
foreach( $categories as $cat ) {
$args = array(
'category__in' => array( $cat ),
'posts_per_page' => -1
);
$cat_query = new WP_Query( $args );
if( $cat_query->have_posts() ) : while( $cat_query->have_posts() ) : $cat_query->the_post();
//enter here, whatever you want to show per post//
endwhile;
endif;
} //end of foreach
Related Posts:
- Different post sort order within different categories
- Setting Custom Sort Order of Posts within a Category
- How to sort posts by last name (2nd word) on ONE category only?
- How to choose a sort order (for posts) per category? (ideally when creating a new category)
- Sort by last word in title
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to sort posts alphabetically based on a specific parent category
- How to Change Order of Posts in Admin?
- How to add metabox for post of specific category
- blog posts sorting doesnt work while using get_query_var
- Manipulate post category after time
- Categories box not showing on post edit pages
- List only child categories a post is in, of a specific parent category
- Add custom field to all posts in specific category
- Exclude category on blog list page
- is there a better way of combining this?
- Possible to create a permalink to sort with meta_key?
- wp_list_categories link to first post of category instead of calling taxonomy template
- WordPress Child Category Display All Posts
- How to display sorted posts in the ‘All Posts’ page
- How to Add ‘Post Categories’ to the Dashboard Sidebar
- How only display all post related to category
- Add category to all post by using sql query?
- Sorting posts according to the term they belong to
- Sorting posts according to view counts not working
- Display posts in alphabetical order for a particular category
- Full Width Main Post
- Direct link to “New post” in specific category?
- Using permalinks, category slugs, and tag slugs
- How do I retrieve then print the currently viewed sub categories?
- Pulling in post category and children within category
- Post categories to pages
- WP_Query: Mixing category__in and tag__in together
- If in_category not working for multiple single.php pages
- Set Default Category to Username
- Listing Specific Categories from Current Post with Depth
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- get_the_category listing in hierarchial order
- How show categories in admin and get that selected to show posts in index
- if in category but only with post meta
- singular posts using archive styling
- Display selected categories onto post page
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- Show posts on front page only
- Change the background of each post according to the category
- Programmatically add posts from specific category to menu
- Post is in descendant category not working in home.php
- How to get posts ordered by using their categories?
- Get post category as a separate string and url
- Display Related Posts by Category in Random
- How to show category based post in home page?
- How to show beneath posts the full category path?
- How to view all posts (on site, not admin) that are uncategorized?
- How to create a list of links to post with specific category
- Display Current Posts Category (with the most posts)?
- Allow / show post comments in category pages
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Display default matabox of posts(add category) wordpress
- How display related post only in Default category on single
- ACF date picker to trigger category change
- Get category slug of the Parent category of a Product
- How to get tags when using publish_post
- exclude particular category in api
- How do you change the permalink for posts for a single category?
- Posts are not displaying on their category and tag page
- Make categories appear random
- how to create a category with wp_insert_post and post_category
- How to add a block to a category page?
- Sorting post by custom field and category
- Excluding category from post navigation in WordPress?
- How to make a page show posts only from specific categories without editing php files
- Get posts from category from custom query
- Post Category link is same with Page link
- How to show posts ordered by random [duplicate]
- How to Get Position of a Post from a category and tag
- Display new posts categories in separated divs
- Querying posts from current category, using a variable as array argument
- Add Categories To Custom Post
- Query posts from newest category
- Precedence of page permalinks over woocommerce product category links?
- Display Posts by Categories
- Ajax – Post Categories and Load More
- Edit Posts Page but not category specific pages?
- Add category selection to function request
- Show Post number of specific Category
- How to organise post by category and date
- Show post if in category
- How to display custom content in post with category XXX
- Displaying categories items among posts
- Displaying different posts Via wp_list_categories()
- Sort Posts Alphabetically by Multiple Categories [duplicate]
- Is possible to create a custom link that creates a post that’s already categorized?
- Category pages vs single post pages
- How to display subcategory articles in the category view?
- Display ONLY Latest Post From Several Categories
- How do we display a certain category type on a page while hiding all others?
- Show all posts in category
- Polylang – display one post into 3 categories with different lang [closed]
- Export Posts Without Categories In An XML File