Need to track the previous job title, and if it’s different, insert your line break.
Untested:
$prev_job_title = null;
while ( $staff->have_posts() ) {
$staff->the_post();
$job_title = get_post_meta( get_the_ID(), 'job_title', true );
if ( $prev_job_title !== $job_title ) {
printf( '<h2>%s</h2>', esc_html( $job_title ) );
$prev_job_title = $job_title;
}
// Staff markup.
}
Related Posts:
- How to put posts with some taxonomy on top of others in `pre_get_posts`
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- WP_Query orderby date not working
- Order by optional meta key?
- Order by DESC, ASC in custom WP_Query
- WP_Query order by multiple meta keys & fields
- Secondary Sort (fallback) for WP_Query
- Query Posts in a Predefined Order
- How to get order of posts?
- How do I order pages and categories by ID or name in the same query?
- WP_Query ordered by custom field that is a date string?
- Merge 2 args in one WP_Query and order it by date
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Revolution Slider Orderby Two Custom Fields
- Order posts ascending with number in title
- List taxonomy terms plus their latest post ordered by post date
- WP_Query order by date in meta_value
- How to use order RAND() on WordPress?
- Show all parents and children in custom post type in right order
- Meta query with order by another custom field
- WordPress WP_Query orderby being overwritten
- WP_Query Order by Specific Post ID First
- Order Posts by meta value AND published date
- How can I pick a single post from the latest 3?
- How do I sort posts with multiple pages
- Order WP_Query by multiple fields, subtracting them from one another
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- pre_get_posts order by not working
- Multiple taxonomy And acf filter group by
- Orderby ASC changes to DESC in WP_Query
- SQL: What is wrong with the following query (generated by WordPress WP_Query, ordering prices)
- Order By table field comment_status in WordPress > 4.0
- WP_Query order result by date AND meta_value
- Order by title without taking into account ‘the’
- WP_Query orderby author__in
- How to orderby multiple meta fields if some fields are empty
- Weird orderby => post__in issue
- Use posts_groupby filter with part of string in wp_query?
- How to order posts by title after they have already been sorted by category
- Advanced ordering of query_posts
- meta_value_num not ordering all items
- How to filter a query by multiple meta keys and order by other meta keys
- Multiple Orderby’s using random order WP_Query
- Debugging wp_query orderby for taxonomy
- WP Query – order posts by meta field first and then order the rest
- How to Create a Random List of Child Pages
- Advanced WP_Query with meta_query, orderby?
- Specify strict ‘order by’ in WordPress query
- Order is breaking wp_query
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- How order posts from category by date and comment count?
- Filtering by multiple conditions in the loop
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Orderby two meta fields not working
- orderby ignored by wp_query
- Sort posts using multiple custom fields and menu_order in single query?
- WP_Query order by multiple meta keys & fields
- What’s wrong with this meta query? (order by meta key, then title, doesn’t work)
- Custom order of posts in wp_query and different taxonomies
- WordPress Query custom ordering by temporary variable
- Custom order revolution sliders post base slides as inserted in Specific Posts List field
- SELECT TOP 1 in wp_query for each groupby meta value
- WP_User_Query Orderby Not Working
- Order posts by tags count?
- Order by meta date with a thousanth of a second defaults to post order
- Query Order By Number Variable From API
- How to get_comments() ordered by date and parent?
- Order 2 meta_queries differently in WP_Query?
- WP Query. Ordering posts by another post types meta
- WP_Query: custom orderby (not ASC nor DESC)
- Best way to query posts and order by relevancy to query
- Order & Orderby clause not working with custom query
- wp_query sorting – one specific meta_key value at last and then sort by create date
- query_posts based on a meta_key
- Display three sequential posts on each page load, without repeating previous
- Order posts by more than one variable (meta_key and publish date AND time)
- Create custom order sortby based on array of id
- Best way to Order Post in Home without a plugin
- orderby in WP_QUERY – Use the order from the Dashboard
- Sort by meta key within same day
- Query All Attachments and Order by Parent Publish Date
- Order Custom Field by Price
- Order posts by custom column using pre_get_posts
- Add filter to Orderby Parameter using Array
- Order WP_Query results in order other than ASC or DESC
- Show sticky post before other WP_Query
- Custom query to order by multiple taxonomies
- Sorting: custom query with orderby meta_value_num THEN by title
- Get post closest to today
- orderby in WP_query doesn’t works
- Posts2Posts, wp_query and orderby issue
- Order by meta values
- Change posts archive ordering
- orderby and order filter in get_posts or WP_query function in wordpress not working
- Why does wp_query only display the most recent post when using order ASC?
- new WP_Query with order args – no more distinction between categories
- Orderby meta _value that is saved as an array
- Conditionaly move certain posts at the bottom of the query result
- WordPress WP_Query custom order_by post_type functionality