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
- How can I change the admin search posts fields?
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- WordPress 4.4+ : How to revision CPT + metadata
- Filter a custom field based on selection of another custom field (ACF) [closed]
- Detect meta value changes when post is updated (post_updated)
- Custom field being erased after autosave
- How to select one major category (or custom taxonomy) for a custom post type?
- Using Query Posts With Multiple Post Types And A Taxonomy
- Display posts if a custom field value is equal to another custom field value
- Custom field default value with counter
- How to use custom fields to enable sticky posts on custom post types?
- Custom meta fields for specific custom type only
- Custom Fields vs Separate Table
- Check if a specific custom field exists?
- WordPress Create Post from front-end
- How to insert content from another Custom Post type into Post?
- Using several custom fields as custom post title
- Calculate all custom field values in the post loop
- add custom field to custom post type
- Role scoping for contributors down to the field level
- Having unique constraints for custom fields in a custom post type
- Display custom fields from custom posts in RSS feed
- A method for ordering mixed dates in search result loop (theory only, no actual code)
- custom comments form for custom post type
- Submitting Custom Post Types with custom fields from Front-end form
- post_per_page ignored in WP_Query
- Sort custom post type by most current date picker
- Remove default WYSIWYG editor without removing custom fields editors
- Display custom meta on page that has been check in custom post type
- How do I update_post_meta() or add_post_meta() with an AJAX call
- Two queries – one with checkbox ticked, one without – comparing meta_query
- Automatically add a character to field in edit post page
- Change Post Meta via AJAX from the posts list table
- Mandatory field in Custom post
- How to store the third party script with HTML code in the wordpress custom input field?
- How To Read Read Custom Post Type Data in Headless CMS Mode
- Filter custom post type admin list by custom meta column, where the column is another custom posts meta value
- How to display custom field in product description?
- Add custom template ‘sub-page’ to Custom Post type?
- Where is get_post_meta value located?
- How to get the posts that my following users are liked?
- WordPress loop, show only one post per custom field
- one get_posts to return a number of custom posts for each meta value
- Is it possible to make one of two custom fields in Custom Post Type UI Required but not the other?
- Get result from Custom Field in Custom Post type
- Advanced search form with filters for custom taxonomies and custom fields
- How to get lowest price from custom fields of posts
- Order Wp Query by earliest of 3 dates meta query