Let me see if I understand your question correctly:
You have the meta values of the player this page belongs to. Then in the loop you have the corresponding meta value of each matched player. All you need to do is compare them:
if($player_position == get_post_meta($post->ID, 'player_position', true)){
// This player is on the same position as the one this player page belongs to
}
If you have a lot of meta values you should avoid writing a lot of if statements, so better use this:
$meta_values_to_compare = array('player_position','player_height');
$matched_meta= array();
foreach ($meta_values_to_compare as $value) {
if($$value == get_post_meta($post->ID, $value, true)){
$matched_meta[]=$value;
}
}
You can then use this array e.g. to set classes on the element or whatever you need to do.
Related Posts:
- Using meta_query, how can i filter by a custom field and order by another one?
- meta_query for keys that aren’t yet set
- Display custom post type and custom fields within a Bootstrap Carousel
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- Querying custom post type with 2 custom fields (date-range)
- How Can I save multiple records in same meta key?
- Getting Bootstrap accordion working in WordPress loop with custom post type (collapsing issue)
- order by meta_value serialized array
- Comparing timestamps in meta query doesn’t work
- Display two post types ordered by two custom fields
- How loop through posts based on custom fields
- Display custom post types with custom date field value (before today) & order by custom date field
- Filtering by Post Meta Custom Fields – Performance
- meta_query compare >= not working but
- WP_Query: include custom post type only with specific meta value
- Returning a list of custom post types excluding those without a specific meta_value
- Two near-identical custom field types – one works, the other doesn’t . What can cause this?
- wp_query check if integer exists in custom field’s array
- Filtering custom post type on a combination of custom taxonomies and custom fields?
- Meta Query Not Returning Output Despite Having Matching Values
- Meta Query Filtering not working on Custom Meta Box using Radio Buttons
- Meta Query posts not showing on ending date of custom field
- Admin Custom Meta Box – Pull Last 5 Posts from Custom Post Type
- Possible to filter custom post type with multiple meta data?
- filter search custom field query
- How to let users choose where to search for posts?
- Query based on custom fields start and end date
- Getting a custom post’s custom field based on another custom post’s custom field select
- Custom Query: If One Post Object Field Value Is The Same As Another
- order the meta query results by 2 custom fields
- Using OR relation in meta_query to check for a value before sorting by another
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Meta query and compare “!=” not working as expected
- Orderby if between two meta fields
- Show posts from WP Custom Post Type selected from a field in a metabox
- 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
- Meta_Query refuses to return results
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- Query events post type after current date and timezone
- Selecting posts older than the current Unix epoch timestamp
- Unable to get the upcoming events for custom post
- WP_Query arguments: Loop through custom post type – get all entries except excluded meta_key?
- loop through custom post-type with two meta_keys
- Querying meta values within an array
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Get Posts ordered by a date custom meta field
- Check for custom field value in different post type than current one and do something
- Function to Compare CPT Post Custom Value with Default Posts CF Value
- WP_Query not using relation key as expected and not producing any results
- Meta query with ACF relationship field
- Query custom fields with three dates – start and end does not work
- Woocommerce custom field search in custom post type [closed]
- Using meta_query and tax_query at the same time
- Add custom field in comments form
- Custom Fields for Custom Post [closed]
- Order Custom Post Type by Custom Field Value
- Filter custom post types by a field value
- Displaying All Posts of a Custom Post Type in WordPress Multisite Backend
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- Custom REST endpoints for a custom post type with custom fields
- How to Create a WordPress Plugin With Custom Post Type/Custom Field Features?
- Hierarchy and access control for Custom Post Types (CPT)
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- search suggest – filter post type
- How to integrate a form (Ninja Form or Contact Form 7) with Custom Post Types?
- First custom field value (out of several) displayed twice after query
- Homepage’s content is dependent on the custom field values (set automatically), how do I get homepage to update without manually updating page?
- Cannot save CPT meta box
- Cross reference custom post types
- Adding Page Templates to post but it ignored it
- Include related custom fields from one post type in another post type’s JSON feed
- frontend image post uploader
- Is there any way to add a “custom field” to the CPT archive page?
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Ordering custom post type by multiple custom fields
- Multiple Frontend Filters Using Advanced Custom Fields
- Custom Post Fields at the beginning of a Custom Permalink
- Integrate Custom Post Type Events into Calendar
- Hierarchical custom fields
- How to get a custom field value of a custom post?
- Fields for different parts of a page
- Is it possible to activate customfield ‘text description’ upon activating the customfield ‘checkbox’?
- Facebook social publisher and custom post type fields [closed]
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- Displaying and searching Custom Posts
- Importing Data from a Non-WordPress database, into WP
- custom comments form for custom post type
- Searching Custom Fields
- Show fields based on taxonomy selection in editor
- Permalinks: custom structure for taxonomy – tags?
- don’t publish custom post type post if a meta data field isn’t valid
- WebP Fallback for Inline Background Image in Style Attribute
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom fields for custom post type