Looping to organize and display custom posts by category using PHP and WordPress
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( … Read more