I am not sure if I get your question right, and thus don’t know if this answer goes into the right direction… Is this what you’re trying to achive?
$apart_locations = $wpdb->get_col( "SELECT meta_value FROM $wpdb->postmeta AS wppm
LEFT JOIN $wpdb->posts AS wpp ON wppm.post_id = wpp.ID
WHERE wppm.meta_key = 'postal_location' AND wpp.post_status="publish"
ORDER BY wppm.meta_value ASC" );
Related Posts:
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- Can’t publish custom post type – “You are not allowed to edit this post.”
- Get_post_custom not fetching value from array wordpress
- Limiting the Number of User Posts to Their Own Posts
- Disable Facebook Comments Automatically On CPT
- How to create content automatically when a post is published?
- Custom Post Type meta value is being saved in array, instead of just the string (as value)
- Importing Data from a Non-WordPress database, into WP
- Getting thumbnails of a custom posts featured images in a page-templates metabox
- List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
- Remove Post Custom Meta Box
- How can I move (or create another) publish button?
- Custom fields for custom post type
- Show future events based on custom field AND order by date
- Meta Data for Custom Post Type not saving
- Using preg_replace to filter custom textarea
- Check if post with same meta value exists
- Filter date from post meta when date is in string format
- Reworking function for counting custom post type posts count
- If Post Meta Equals Current Title Conditional Advanced Custom Fields
- Is there a way to exclude posts based on meta_values?
- Number of posts in the archive
- Custom query for custom post_type
- Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Archieve.php not loading for custom post type
- Submitting Custom Post Types with custom fields from Front-end form
- detect when a custom post is cretaed for the first time
- create custom meta box with default value
- Get $post->ID from a URL
- Displaying a div from an assigned meta_value when on a page
- Meta data (Tags and Categories) for Custom Posts not showing.
- Display different information of a custom post type
- Create Array from custom post type to display a slider
- Setting Post Title via Meta Data returns Auto-draft
- How to Echo Metadata Value in Currency Format
- Issue on Working with Metabox – Checkbox to enable Sale Items
- Filter posts by tax (dropdown) and meta value
- delete_post_meta() for whole CPT / multiple posts?
- How to get specific post meta by title or id
- Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”
- Publish and save specific postmeta to a filtered post_type
- populate array with posts
- How to Make infinite loop of post
- How to move a post to different post type with all meta data?
- get_posts seems to be skipping the last Post
- Why do I have to press the “Update” button twice to save my meta box values?
- Displaying multiple post types on home page
- Conflict between wp_list_pages and get_posts – list pages not displaying
- How can I display a drop-down select of Post Names
- how to show records that don’t have custom meta value
- WP API Response does not show my registered metadata
- How to detect that the save_post hook is calling the callback associated to the current edit post page only
- $post->post_meta not pulling any post in wordpress/php
- Values from meta-box not on $_POST
- Return number of all custom posts type by author in all statuses
- WP_Query of custom post type sorted by meta_key has unexpected results
- Returning a custom content types with meta values
- Custom post type suddenly stoped working after WordPress 5 update
- Batch Extract Date from post title and put into ACF custom field
- Is it possible to use array_walk() to append terms to an array of posts?
- custom hierarchical taxonomy and custom post type list contains surplus posts
- copy images from custom field to another custom field
- How to show custom field on specific custom post type posts only when filled
- How to handle this specific case of custom post type?
- Save CTP post meta different values each day without overwriting previous values
- get_post_meta returns NULL in front-end, but correct result in back-end
- Cannot obtain custom meta information
- Problem with adding custom post type meta to header by plugin
- is_main_query() never called on WP 4.4
- Group by custom field value (start and end times)
- meta query not retrieving posts
- How can I output WPAlchemy repeating fields meta values in my page template?
- Meta box data is saved but NOT displayed in the meta box text field. Why?
- How to call a post’s metadata in shortcode.php?
- How to get custom post type title, excerpt, thumbnail and permalink by post ID?
- Save Metabox Custom Field Value
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- Meta box data not saving
- Get all metadata for a given custom post type
- Get posts by category name
- WP_Meta_Query object with conditionals
- Trying to write shortcode with get_post_meta but isn’t working
- Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
- Related posts meta_query CPT
- Meta box with front-end styling
- Sanitaizing Select Optin For Custom Post Type Metabox in WP
- How can I get some of a posts meta data whilst it is still inserting?
- How to properly use Categories with Custom Post Types
- How to retrive Custom Post Type Meta Fields in Custom WP_Query
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Advanced custom field – posted fields from custom post type
- Cannot Save MetaBox Data in Custom Post Type
- delete duplicate meta_value with same post_id
- HM CMB: Post Select Field for CPT ID
- Search CPT Title AND Meta
- Getting WordPress to store 0 values for custom post type meta
- 4 posts per page from single category
- updating one custom meta field only