Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Get only used meta_values

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:

  1. How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
  2. Can’t publish custom post type – “You are not allowed to edit this post.”
  3. Get_post_custom not fetching value from array wordpress
  4. Limiting the Number of User Posts to Their Own Posts
  5. Disable Facebook Comments Automatically On CPT
  6. How to create content automatically when a post is published?
  7. Custom Post Type meta value is being saved in array, instead of just the string (as value)
  8. Importing Data from a Non-WordPress database, into WP
  9. Getting thumbnails of a custom posts featured images in a page-templates metabox
  10. List Taxonomies: Don’t list taxonomy if it has no post – depending on custom post-meta?
  11. Remove Post Custom Meta Box
  12. How can I move (or create another) publish button?
  13. Custom fields for custom post type
  14. Show future events based on custom field AND order by date
  15. Meta Data for Custom Post Type not saving
  16. Using preg_replace to filter custom textarea
  17. Check if post with same meta value exists
  18. Filter date from post meta when date is in string format
  19. Reworking function for counting custom post type posts count
  20. If Post Meta Equals Current Title Conditional Advanced Custom Fields
  21. Is there a way to exclude posts based on meta_values?
  22. Number of posts in the archive
  23. Custom query for custom post_type
  24. Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
  25. Recoverable Fatal Error – Object of class WP_Post could not be converted to string
  26. Archieve.php not loading for custom post type
  27. Submitting Custom Post Types with custom fields from Front-end form
  28. detect when a custom post is cretaed for the first time
  29. create custom meta box with default value
  30. Get $post->ID from a URL
  31. Displaying a div from an assigned meta_value when on a page
  32. Meta data (Tags and Categories) for Custom Posts not showing.
  33. Display different information of a custom post type
  34. Create Array from custom post type to display a slider
  35. Setting Post Title via Meta Data returns Auto-draft
  36. How to Echo Metadata Value in Currency Format
  37. Issue on Working with Metabox – Checkbox to enable Sale Items
  38. Filter posts by tax (dropdown) and meta value
  39. delete_post_meta() for whole CPT / multiple posts?
  40. How to get specific post meta by title or id
  41. Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”
  42. Publish and save specific postmeta to a filtered post_type
  43. populate array with posts
  44. How to Make infinite loop of post
  45. How to move a post to different post type with all meta data?
  46. get_posts seems to be skipping the last Post
  47. Why do I have to press the “Update” button twice to save my meta box values?
  48. Displaying multiple post types on home page
  49. Conflict between wp_list_pages and get_posts – list pages not displaying
  50. How can I display a drop-down select of Post Names
  51. how to show records that don’t have custom meta value
  52. WP API Response does not show my registered metadata
  53. How to detect that the save_post hook is calling the callback associated to the current edit post page only
  54. $post->post_meta not pulling any post in wordpress/php
  55. Values from meta-box not on $_POST
  56. Return number of all custom posts type by author in all statuses
  57. WP_Query of custom post type sorted by meta_key has unexpected results
  58. Returning a custom content types with meta values
  59. Custom post type suddenly stoped working after WordPress 5 update
  60. Batch Extract Date from post title and put into ACF custom field
  61. Is it possible to use array_walk() to append terms to an array of posts?
  62. custom hierarchical taxonomy and custom post type list contains surplus posts
  63. copy images from custom field to another custom field
  64. How to show custom field on specific custom post type posts only when filled
  65. How to handle this specific case of custom post type?
  66. Save CTP post meta different values each day without overwriting previous values
  67. get_post_meta returns NULL in front-end, but correct result in back-end
  68. Cannot obtain custom meta information
  69. Problem with adding custom post type meta to header by plugin
  70. is_main_query() never called on WP 4.4
  71. Group by custom field value (start and end times)
  72. meta query not retrieving posts
  73. How can I output WPAlchemy repeating fields meta values in my page template?
  74. Meta box data is saved but NOT displayed in the meta box text field. Why?
  75. How to call a post’s metadata in shortcode.php?
  76. How to get custom post type title, excerpt, thumbnail and permalink by post ID?
  77. Save Metabox Custom Field Value
  78. Echo custom post meta from options array
  79. Value of post meta dropdown is not showing in WordPress
  80. Meta box data not saving
  81. Get all metadata for a given custom post type
  82. Get posts by category name
  83. WP_Meta_Query object with conditionals
  84. Trying to write shortcode with get_post_meta but isn’t working
  85. Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
  86. Related posts meta_query CPT
  87. Meta box with front-end styling
  88. Sanitaizing Select Optin For Custom Post Type Metabox in WP
  89. How can I get some of a posts meta data whilst it is still inserting?
  90. How to properly use Categories with Custom Post Types
  91. How to retrive Custom Post Type Meta Fields in Custom WP_Query
  92. Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
  93. Advanced custom field – posted fields from custom post type
  94. Cannot Save MetaBox Data in Custom Post Type
  95. delete duplicate meta_value with same post_id
  96. HM CMB: Post Select Field for CPT ID
  97. Search CPT Title AND Meta
  98. Getting WordPress to store 0 values for custom post type meta
  99. 4 posts per page from single category
  100. updating one custom meta field only
Categories custom-post-types Tags custom-post-types, get-posts, post-meta, publish
Change default italic from to in admin editor
how much php coding do i need to know in order to create web blog using wordpress.org

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress