add_filter('post_class', function($classes){
global $wp_query;
static $meta = array();
// first call gathers meta values
if(!$meta)
foreach($wp_query->posts as $post)
$meta[$post->ID] = get_post_meta($post->ID, 'your_meta_key', true);
// $wp_query->post should be the global (current) $post object
$this_meta = $meta[$wp_query->post->ID];
if($this_meta){
$counts = array_count_values($meta);
if($counts[$this_meta] > 1)
$classes[] = 'your_class';
}
return $classes;
});
(untested)
Related Posts:
- Detect meta value changes when post is updated (post_updated)
- Displaying Meta Box Image
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Populate Custom Fields in a Custom Post Type?
- How to check if user meta field is empty in conditional else statement
- A better way to add a meta box to custom post types
- create custom meta box with default value
- How can I output WPAlchemy repeating fields meta values in my page template?
- Add a meta field to the list of results for a custom post type
- Empty meta-box returns publishdate if no value is set?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- Delete custom post type metadata without deleting the post in admin area
- what is the correct way to compare dates in a WP query_posts meta_query
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- echo value from ‘select’ field type into page template using cmb2?
- How to get custom metabox image field?
- Search everything (posts, pages, tags, cpt, meta)
- Custom field being erased after autosave
- Order custom posts by a date metabox
- How to select one major category (or custom taxonomy) for a custom post type?
- How to sort CPT by custom meta value (date), and return posts month by month
- How to get source of custom meta image?
- How can I include meta box content when searching?
- update a post meta from a single table cell TablePress
- update custom post type meta from a shortcode
- Custom Meta Boxes – Nonce Issue – Move to trash issue
- Show metabox in custom-post-template depending on taxonomy term?
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Displaying custom posts only if custom meta box’s date is not expired
- Display custom post on home page based on a metabox selection
- Displaying Metabox value (custom post type taxonomy)
- How can I display my custom metaboxes on a custom post template?
- get_post_meta is returning image id
- Create a random unique 6 digit number as custom field for custom post type
- Why do I lose the content of meta boxes when I leave the page?
- how to interconnect custom post types?
- Adding dropdown select meta box to custom post type – seems restAPI is interfering
- Keep display metadata value on backend – Custom Metabox
- Populate dropdown from one custom post type inside another custom post type
- Why is my select meta data not saving?
- Visual editor issue by having multiple tiny mce editors in a CPT
- Plugin – Combine Meta Box Input Fields into single saveble record
- Two Custom Post Types Many to Many Relationship
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Grouping metadatas into one
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Show Custom Post Type meta boxes only on Page Edit
- Adding Page Templates to post but it ignored it
- Importing Data from a Non-WordPress database, into WP
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Custom “radio button meta box” not saving correctly
- Meta Data for Custom Post Type not saving
- Check if post with same meta value exists
- Display Repeatable Meta Box Content
- Displaying a div from an assigned meta_value when on a page
- What do the numbers mean at the end of add_action(‘save_post’)…?
- A meta box (in a custom post type) with two different type of fields
- Values from meta-box not on $_POST
- Custom post type suddenly stoped working after WordPress 5 update
- copy images from custom field to another custom field
- How to show custom field on specific custom post type posts only when filled
- Reusable metabox backend and frontend
- Cannot obtain custom meta information
- Display custom meta on page that has been check in custom post type
- How can I modify a custom post type and custom page template for a child theme if all content seams to be handled by theme’s ‘native’ plugin?
- Save Metabox Custom Field Value
- Meta box data not saving
- Related posts meta_query CPT
- Meta box with front-end styling
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- Cannot Save MetaBox Data in Custom Post Type
- Adding an extra parameter [string] to my posts’ permalink?
- Problem On Retrieving Post Meta Data on Custom Column [closed]
- Saving metabox keys and storing values as array
- How to keep custom post type related information
- How to avoid duplicate posts queried from custom meta?
- Where is get_post_meta value located?
- PHP Warning with Custom Fields
- Simple Data picker meta box
- Metaboxes in Loop
- Add more custom fields when creating a new custom post type
- Custom meta box data not saving
- How do I extract the contents of a CPT’s custom field for all posts?
- Collect custom post in a calendar
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- Problem with ‘save_post’ hook not running
- Howto: use existing post_meta as options for a different metabox (checkboxes or list)
- Display a post count from a custom metabox selection
- Filter CPT based on meta box value using Flexible Posts widget?
- Advanced search form with filters for custom taxonomies and custom fields
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- Custom meta box includes
- Querying meta values within an array
- Creating entries with image attachements within posts and managing them in a list
- Post AND page parameter for WP function
- Display div based on Group metabox selection [closed]
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- Check for custom field value in different post type than current one and do something
- How to consume external API from WordPress post editor and display the response data in the custom field?