So you want the values 108,78,90
corresponding to the meta key ‘areas’ for the post with ID 94?
First retrieve those IDs:
$the_post_id = 94;
$area_ids = get_post_meta( $the_post_id, 'areas', false );
//Make sure they're all positive integers
$area_ids = array_map( 'absint', $area_ids );
if( $area_ids ){
//We have IDs, retrieve posts
$areas = get_posts( array(
'post_type' => 'area',
'numberposts' => -1,
'post__in' => $area_ids;
));
if( $areas ){
//We have areas
foreach( $areas as $area ){
echo get_the_title( $area ). '<br/>';
}
}
}
The above has not been tested, but should work in theory. If you want $the_post_id
to the be ID of the post currently being viewed then you can use get_the_ID()
.
Related Posts:
- WP_Query orderby date not working
- Best way to detect if you are in a SINGLE POST page
- How to do a wp_query using “BETWEEN” with two meta_values?
- Better way to get tag stats?
- Query two taxonomies via URL or link?
- How do I order pages and categories by ID or name in the same query?
- wp_query order by title
- Sort posts by custom taxonomy name
- Wp_query order by multiple custom fields?
- Would this post meta be better added to the post table rather than post_meta table
- meta_query on a date range using an array of values
- Get product list of given category
- How to exclude products by tag from woocommerce shop page?
- Filtering posts by custom field value not working
- wpdb get results doesn’t work with variable
- Query Ignoring ‘exclude’ Parameter?
- Custom pagination with WP_Query generating 404 error
- Query post with meta_query where date is not in future
- Apply CSS class to every second database record [closed]
- How to prevent writing duplicate loops?
- merge two query arguments into one WP_Query call
- Adding a parameter to the default query
- Using WP_Query in “parse_query” or “pre_get_post” in Posts2Posts
- Taxonomy search/filter with multiple taxonomies and multiple taxonomy terms
- How do I change the order (ASC and DESC) in the following retrieval method using WP_Query?
- While creating Block Themes in WordPress, how can I query custom posts for an Archive view?
- How To Fix WP Query Returns Results But Shouldn’t?
- Weird orderby => post__in issue
- how to handle multiple ajax wordpress queries?
- How to extract specific post
- wp_Qwery works to slow
- Search for “2nd” also returns “22nd” in wp_query
- Custom post type archive pagination query issue
- 2 weeks ago from meta query meta value
- WP Group posts by year(desc) > month(desc) > date(asc)
- Running main loop 2 times with conditional statement
- paged variable not working for category/custom post archive
- How to output the title of the blogs home page
- Array as ‘key’ in WP_Query
- Check the Specific Meta Key IF its Meta Value is Empty then… (WP Post Meta Query)
- Searching for meta_key returns 0 posts
- Using custom taxonomies in a query
- Determining Author post count
- How I can change the condition or compare operator for WP_Query in pre_get_posts
- Apply filters to main query instead of creating new one?
- WP_Query returns different results from get_posts() [closed]
- How to pass query string vars between admin pages?
- Query posts by Post title
- Why having more than 10 clauses in WP_Query results in some outputs being dropped?
- mysql query order by
- WP_User_Query and user posts
- Why do I have to use pre_get_posts with custom WP_Query to reset posts_per_page?
- WP order ASC in custom author loop
- Using rewind_posts for displaying multiple categories
- Query to get last posts from authors of blog
- Custom Homepage Pagination using WP_Query
- My website is getting too many dierect home arechives and this is increasing my bounce rate
- How to get latest post excerpt from a specific category?
- Get all content on a “single page” site depending on language
- Get list of all Grandchild Pages
- get latest added term from taxonomy and insert into php variable
- Featured images loop for Orbit Slider
- Trouble passing attribute into shortcode function
- WP_Query return posts in wrong order
- Exclude post with taxonomy and from the terms (taxonomy & tag) posts count
- WordPress search WP_Query to cover multiple post types and their custom fields?
- How do i create a custom post query when the meta value is an array?
- How to do WP_User_Query for Nested Array value Inside Nested Array field
- Display the search results like the original pages
- Pagination on archive.php not working?
- How to use jQuery validation to set the search bar to accept only a specific input?
- How to filter on placeholder image
- How to compare between two dates in a nested loop?
- How to query 5 users in random who have published more than 10 posts
- WP query for two post types how to order newest to oldest with two different meta fields?
- Order & Orderby clause not working with custom query
- WP_Query doesn’t works inside loop
- How to redirect a query string to a “virtual” subdirectory
- WP_Query returns images but post_per_page is incorrect
- Problem with custom WP_Query and underlying pagination/posts_per_page
- WP_Query with child element
- Select posts wich has no relationship in custom taxonomy
- WordPress Query posts that have title > another title
- Custom query to order by multiple taxonomies
- Custom post type archive organized by category
- Different sql queries count indicator on the main page [closed]
- Query Posts to fetch Posts with Unique Tag
- Can’t figure out query logic
- Convert a WP Query into a simpler SQL query to fetch only COUNT of posts
- Duplicate posts showing up in loop using infinite scroll
- WP_Query orderby not working on custom post_type
- wp_query->set for several categories
- How to order “top rated” results by date and meta key?
- Getting posts via WP Query
- Print post data inside loop using theme content template
- Where to find WP_Query class?
- Elementor custom query
- Get access to all terms associated to each post that the wp_query loop displays
- Using ‘meta_query’ with the ‘pre_get_posts()’ hook disables searching for post titles
- How to save the results of a query as a php file for an autocomplete search bar