Add this after $args
$categories = get_terms('category', $args); //get all categories
$count = count($categories ); //count categories
if ( $count > 0 ){ //Check if you got some categories
foreach ( $categories as $category ) {
$args['cat'] = $category->term_id; //get the id of each category and add it as a parameter
$loop_our_work = new WP_Query( $args ); //start a new query with 'cat' parameter inside of it for each category
if($loop_our_work ->have_posts()) { //always check if query have posts
//echo here category name or whatever you need about category
while( $loop_our_work ->have_posts() ) : $loop_our_work ->the_post();
//echo here whatever you need for each post on current category inside the loop
endwhile;
} //endif
The code is not tested but i hope it helps you
Related Posts:
- List events by month
- Custom post type loops with different page templates
- How do you output custom code between posts in the loop?
- How to append element after thumbnail
- Display custom field of specific post where post title matches variable
- Create a random unique 6 digit number as custom field for custom post type
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Very Slow Page – How to Optimize # of Queries?
- Custom Post Type Loop throws 500 error when used in widget
- How to make sure content doesn’t display if selection is empty
- CPT + CMB2: data not displaying for only first post in loop
- How do i calculate the total of values of custom fields in custom post types?
- I would like to have different styles for my posts based on the content of each post
- Checking if Post Title is Unique as Loop Criteria
- Custom Tag Description unable to display just below and outside of the Loop
- Including all post id’s of a custom post type into an array
- How can I group posts by months and years?
- Trying to Create a PHP Variable for post_type that can be referenced Site Wide
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- Control content before and after custom post type loop
- Get data from PHP to JavaScript to set position of each post on front page
- foreach loop inside the loop creating duplicates in output
- Compare Two Custom Post Types Using The Same Custom Taxonomy
- How can I increase the post count for custom post types only?
- Show the categories the current post has
- Fetch data from two custom post types and create multidimensional array for output to html table
- Page that lists publications by classifying them by taxonomy
- CPT loop doesn’t seem to account for post date?
- Pagination not working in custom post type. Help
- when looping through custom post data not appearing
- Accessing download link from the loop with WP Download Manager Pro
- Custom Post Type has wrong label and is not found when called by a loop
- Combine multiple separate lists into one
- Show parent category and subcategory once in while loop
- WordPress trying to query two custom types to get child from the parent
- Add active class to foundation 6 tabs while looping categories
- Display related post content and custom field content
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- WordPress query posts by custom post type not workng
- WordPress Custom Post Type and sort by Tags
- Posts without featured image using other post’s featured image
- Order by custom field attribute
- Looping taxonomy in taxonomy?
- Query Custom Post Type by Tag
- How do I filter a custom post type loop by a field?
- How can I remove the “Add New” button in my custom post type?
- Categories under custom post types doesn’t show properly
- How to display the rest of categories on Portfolio filterable
- Get_post_meta() won’t return value
- How to get current post id of a custom post type in a loop using template singel-{custom type}.php?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- get_template_part for custom post type content not working
- Creating Accordians in WordPress Theme
- Display different content on homepage depending on post type
- What’s the difference between same wp functions get_posts(); functions in different form?
- WP_Query orderby modified to include custom meta changes
- how to check if custom post type column already exists?
- Can I list a custom post type within another custom post type in the admin area?
- Custom post type multiple loop by taxonomy term
- List custom taxonomy specific to one custom post type
- Custom post type, organized by categories
- What’s the WP way to load remaining custom posts?
- Saving fields in a drop-down in WordPress
- Assigning a category to a custom post type in WordPress
- I need to add a filter to prepend the term ‘National – ‘ to the post title if the post is tagged to multiple states
- WordPress: Custom User Role cannot access Custom Post Type | “Sorry, you are not allowed to access this page”
- Accessing a protected property of a post
- Display post from custom post type
- WordPress giving a 404 page when passing a year argument different than the current year
- Drop down list with posts within the “add new” page
- WordPress sitemap with Custom Post Types
- How can I sort the order of multiple custom field values in a custom post type?
- How can I loop at a Specific Taxonomy from a custom post type?
- Update query based on CPT / Post Type, show all sorted by date
- php dynamic content inside shortcode
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- How to avoid duplicate posts queried from custom meta?
- pagination problem listing custom post types of taxonomy in wordpress
- In the php, how can I have a category of a custom post type display?
- Why do my custom post type show up in all pages?
- Taxonomy doesn’t follow slug permalink structure
- Staggering featured post using ‘sticky’
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- next_posts_link() always generates second page link on custom post type
- Show posts for current taxonomy
- Multiple loops for custom post type to spread data across rows
- wordpress form processing to custom post type not working
- Loop multiple taxonomy in custom post
- $post breaking container loop
- WordPress custom field images not getting inserted into array
- Nested loop called with shortcode duplicating the content above the main loop
- why get_post_meta is returning 0?
- Show search for data extracted from metabox
- Get all active posts that are tied to a custom taxonomy for a custom post type
- Custom post type is_singular condtional not working when managing sidebar display