You could try a concept like the following (post your loop and I will improve the model):
$state_group = 'Open Loop';
// start the loop
// if posts then while
$state_code = // lookup this post state code
if ( $state_code != $state_group ){
echo $state_code;
$state_group = $state_code;
}
//end loop
Related Posts:
- How to make a shortcode for my WP_Query Loop? [duplicate]
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- Conditional to modify query results
- wp_query to find posts by year and month
- Create a random unique 6 digit number as custom field for custom post type
- Very Slow Page – How to Optimize # of Queries?
- WP_Query orderby modified to include custom meta changes
- How to make sure content doesn’t display if selection is empty
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- How can I group posts by months and years?
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- Having Issue on Ordering CPT by Custom Field In Custom WP Query
- Get data from PHP to JavaScript to set position of each post on front page
- foreach loop inside the loop creating duplicates in output
- How do I list a custom field and custom taxonomies for each result in a loop?
- Page that lists publications by classifying them by taxonomy
- Alike Shortcode using in Custom Shortcode
- Query custom post type that has a serialized relational advanced custom field value
- Sort custom post column by generated value?
- when looping through custom post data not appearing
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- sorting in wp query based on custom field value
- WordPress query in which condition uses custom field
- Error in WP Query. If variable is empty it is displaying previous post value
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- Order by custom field attribute
- Query Custom Post Type by Tag
- How do I filter a custom post type loop by a field?
- Multiple orderby values in WP_Query
- How do you get the count of posts in an archive page?
- how to filter by last name for custom post
- Search that will look in custom field, post title and post content
- Filtering a WP Query result
- Display Custom Post Type Fields
- WordPress query by multiple Custom fields and order by date
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- WP Query group/order by category name
- exclude custom post type by meta key in wp_query
- Unable to get post content from custom post type loop
- Display custom field of specific post where post title matches variable
- How to dynamically attach pictures to a carousel
- Remove duplicated values from a loop
- How to connect two custom post types with nested loops
- Custom Post type and Custom Field WP_Query
- Custom Post Type Loop throws 500 error when used in widget
- WordPress custom loop filter by meta_key and value with serialize data
- Show one item per category of a custom post type
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Custom Tag Description unable to display just below and outside of the Loop
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Problem: wp_query outputs all images on site
- First custom field value (out of several) displayed twice after query
- Displaying custom field according to date
- Add additional field to custom post_type
- Custom WP_Query doesn’t display all posts
- Query & the_content() is showing in the header
- How to conditionally add Custom Post Type to Front Page
- Pagination not working on custom query on a page
- Undefined $post in wp_query
- Get post content from another section in custom single page
- Group by custom field value (start and end times)
- Custom PT, Taxonomys and wordpress query
- Displaying Posts Using a Custom Query with a Custom Field and a term_id
- How can i loop through custom post type according to custom meta field?
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Fetch data from two custom post types and create multidimensional array for output to html table
- Create an user checklist system for a course plateform using ACF Pro and ACF Extended
- How to sort WP_Query by a custom text field (written as a date dd/mm/yyyy)
- Exclude a specific post in a Custom Post Type
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- WP_Query get always custom post_type for first
- Filtering posts based on three taxonomies
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- wp_post_delete is deleting all offices
- 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
- Query custom post type and custom field by URL parameters
- Combine multiple separate lists into one
- Error in the page of a CPT file in WordPress
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Custom post types – meta_query: search lesson which starts sooner
- Custom taxonomy template for custom fields loop [closed]
- The most recent post of custom taxonomy
- Get month and day from a Date Picker custom field
- Show Custom Post Type taxonomy term that matches custom field
- Select Menu for Custom post Type does not save
- next_posts_link returns same content of 1st page
- Custom loop won’t work, can’t find problem
- loop through custom post-type with two meta_keys
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- How to exclude certain portfolios from a loop
- Display ACF object field data using Elementor Custom Query
- WordPress custom field sorting, weird behavior: the latest post is at the end
- How to insert a post from a different post type after every nth post
- Complex Custom Loop with Includes