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

Combining two meta_values within one row with query

You can use the WP_User_Query class which works much like WP_Query.

The docs: http://codex.wordpress.org/Class_Reference/WP_User_Query

Below is a dump of the WP_User object that it will return, in this example using:

$wp_user_search = new WP_User_Query( array( 'fields' => 'all_with_meta' ) );
$get_users = $wp_user_search->get_results(); 

user var_dump

This should set you in the right direction because it was not obvious how your new meta_keys are set up and exactly how you want to run the query. The second question isn’t really related to WordPress 🙂

If you don’t want to use WP_User_Query you will have to use $wpdb which is more direct mySQL query.

it would be something like:

global $wpdb;
$get_map_user = $wpdb->get_results("SELECT * from $wpdb->usermeta WHERE meta_key = 'bid_user_lat'");

It would probably be better if you had one meta_key with 2 values for your long/lat, instead of 2 meta keys.

http://codex.wordpress.org/Class_Reference/wpdb

Related Posts:

  1. Sort users in admin screen by meta value whether it exists or not
  2. Search custom post type by meta data
  3. How to display liked posts of current user in wordpress?
  4. Filter query posts by the count of metas for a meta key
  5. Save default value for empty or missing post meta
  6. Grouping related postmeta data via SQL query
  7. Select User by Joining Multiple Meta Value Results
  8. mySQL query. ORDER BY meta_key
  9. Remove posts from query for events whose start date has passed
  10. Query metas (and not : query posts by metas)
  11. Issue with using add_rewrite_rule() for post querying custom fields
  12. Plugin will sort users by usermeta
  13. Problem when try to add ++1 for user meta
  14. Query posts according to specific post meta values
  15. Order by meta value pro first then meta value free in my search function
  16. How to exclude posts for current user
  17. Query Nickname rather than Display Name in custom Woocommerce plugin
  18. WP_User_Query with more than two custom meta values
  19. get_post_meta with WP_query
  20. Declaring a var, placing it in a query and using the output of the query?
  21. Compare User meta_value with Product meta_value
  22. How to do WP_User_Query for Nested Array value Inside Nested Array field
  23. How to do a sql like query on serialized data of user meta data
  24. Is there any way to get all custom posts and all custom terms with it’s meta in few queries?
  25. Sort by postmeta on when searching
  26. Use $wpdb->get_results with filter based on array
  27. Querying users by meta value and getting a strange answer
  28. What is the best way to query posts based on live data?
  29. Update vs Insert logic but the last key is always inserted?
  30. Custom MySQL Query for Post and Post Meta
  31. Sort users by custom user meta value
  32. list or get meta_key where meta_value is ‘something’
  33. How to display SQL query that ran in query?
  34. How can I create a meta_query with an array as meta_field?
  35. Query multiple meta key values?
  36. How to Optimize WP site for millions of posts
  37. order by numeric value for meta value
  38. how to get list of all users and their metadata
  39. How to get comments by post ID?
  40. Differences between wpdb->get_results() and wpdb->query()
  41. Is there a way of increasing the speed of this query?
  42. Query users by custom taxonomy and user role
  43. Get all image from single page using this query
  44. How can I query all users who registered today?
  45. Get Terms by IDs with IDs order
  46. Reversing the order of posts AFTER the query is performed
  47. what are the numbers between curly brackets in search query
  48. simple sql query on wp_postmeta very slow
  49. Using WordPress public query variables
  50. How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
  51. When/why does ‘$query->get( ‘tax_query’ );’ return empty?
  52. How to get link and title of next and previous post on single page
  53. Create pagination and order according to alphabet
  54. wpdb get posts by taxonomy SQL
  55. How to List Events by Year and Month Using Advanced Custom Fields?
  56. What is the most efficient way of querying posts based on visits and date for current day?
  57. Can I count the number of users matching a value in a multiple value key?
  58. Is there any difference between hooks posts_where with posts_join and posts_search performance wise?
  59. Content hooks vs User hooks
  60. wordpress query – orderby child post date
  61. How to search display_name column when using WP_User_Query
  62. How many WordPress SQL Queries per page?
  63. How to order WP_User_Query results to match the order of an array of user IDs?
  64. How to display Section for certain time
  65. Add multiple value to a query variable in WordPress
  66. Getting all user metadata from user
  67. Custom query_var causes displaying posts archive on front page
  68. Slow wp_enqueue_media()
  69. Multipart/formatted MySQL query problem
  70. Custom Queries: Joining On Meta Values From Two Custom Post Types
  71. What is the most efficient way of implementing a favorite post system?
  72. Query Custom Meta Value with Increment
  73. Wp_User_Query not sorting by meta key
  74. Remove [gallery] shortcode altogether
  75. Compare two numeric custom fields
  76. wp_dropdown_categories with multiple select
  77. Advanced Custom Fields – Query Efficiency
  78. Why does get_the_time(‘F j’) return November 30 for all posts?
  79. WP_User_Query with combined meta query – not working?
  80. Check if WP_User_Query ‘include’ is empty
  81. Query by one meta_key and sort by another (possibly NULL value)
  82. How to tune search argument in WP_Query to show only exactly the same results?
  83. Custom query filter not working on woocommerce category page
  84. How to delete a transient on post/page publish?
  85. WPDB Multiple site’s posts and get featured images
  86. Very slow query
  87. query multiple taxonomy and show post count
  88. Search Terms – Querying on either description__like OR name__like in the same Term Query?
  89. Searching user meta using WP_User_Query
  90. Query & Sort Comments by custom comment meta
  91. How to get my loop to pull posts into three columns
  92. SQL query equivalent to WP User Query
  93. How to display lastest post date in the homepage?
  94. Custom $wpdb Query for Custom Post Type by Category
  95. Get a user’s most recent post title
  96. Creating a custom post type upon registration
  97. Categories and products in random order
  98. add_query_arg() XSS Vulnerability
  99. Count user posts by user ID, Post type and Post status
  100. Can’t pass table to $wpdb->prepare
Categories query Tags post-meta, query, user-meta, wp-user-query
How do I centre all page titles site wide without centring post titles or site title?
event organiser not loading in main content area

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