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

How to create meta fields with more than 1 relation?

A better approach would be to save two meta fields. One for the candidateID and one for the recruiter.

Then when you need to query the posts you should use the WP_Meta_Query with both meta fields and the relation argument set to ‘AND’:

$args = array(
  'post_type'  => 'opening',
  'meta_query' => array(
    'relation' => 'AND',
    array(
      'key'     => 'open_candidate',
      'value'   => $candidateID,
      'compare' => '='
    ),
    array(
      'key'     => 'recruiter',
      'value'   => $recruiterID,
      'compare' => '='
    )
  )
);

$posts = new WP_Query( $args );

Or if you have the post and need to find the candidate and the recruiter, you can just use:

$candidateID = get_post_meta( $post_id, 'open_candidate', true );
$recruiter = get_post_meta( $post_id, 'recruiter', true );

This hasn’t been tested but it should work.

Codex reference for WP_Meta_Query: https://codex.wordpress.org/Class_Reference/WP_Meta_Query

Related Posts:

  1. How to share category taxonomy with custom post type (The Event Calendar plugin)
  2. Query Posts by Custom Field ‘Price’
  3. Custom Taxonomy in plugin and template
  4. Update Multiple Post Meta for the Same Post In One call?
  5. How to make a list of companies’ information and display them to user, using custom post types and a custom taxonomy?
  6. Add .html extension to custom post type taxonomies
  7. Comparisson between date() and a date from wp_postmeta
  8. Show the “ratingValue” and “ratingCount” values ​of KK Star Ratings Plugin
  9. Updating post meta for custom post types
  10. How can I add a custom meta value on file upload?
  11. remove custom taxonomy metabox form custom post type
  12. Custom Post Type causes Page Not Found
  13. How to get custom field image url of specific size
  14. How to delete terms on plugin deactivate?
  15. Woocommerce custom shared taxonomy
  16. taxonomy_template filter do not loads custom taxonomy template properly
  17. Set attached to state
  18. Plugin allowing for artists, events and venues
  19. How to add rewrite rules and pagination to retrieve attachments files?
  20. Make the checkbox meta field checked by default
  21. Show Heirachy of categories in WP Download Monitor
  22. Custom Taxonomy Tag Search
  23. Possible to replicate economist.com’s debate section in wordpress? [closed]
  24. Where to hook my plugin’s action
  25. Is there a filter for get_post_custom()?
  26. WP plugins for building a database?
  27. Loco Translate: Custom Post and Custom Taxonomy Labels not translated in wp-admin menu
  28. Is Wrapping intval() Around esc_attr() Redundant for Escaping Input?
  29. WordPress category add image field
  30. Where (or when) should I register a new taxonomy?
  31. Limit Number of Taxonomy Terms (Images) Displayed
  32. Widget for adding HTML markup to a page
  33. Create digital-virtual-downloadable WooCommerce products from the frontend using Gravity Forms? [closed]
  34. List taxonomy terms for post as checkboxes
  35. Assign / update custom field value for all posts (How can I assign only to posts without custom field value?)
  36. How to display the “ratingValue” and “ratingCount” values ​generated by the KK Star Ratings plugin into my page’s recipe ld+json schema
  37. ‘No Results Found’ on single post for custom post type
  38. get current date + 90 days and checking every day
  39. auto populate list of questions if user select a category xyz
  40. Metabox not show in categories custom post type cmb2
  41. How to set taxonomy in custom plugin?
  42. How can I change the meta_key for a particular piece of information?
  43. WP_Terms_List_Table Quick Edit not working
  44. “Custom Post Type Permalinks” plugin URL strcuture
  45. Ordering taxonomies by rank
  46. Plugin generated taxonomies’ permalinks with custom placeholders
  47. Meta box losing its value when scheduled post is published
  48. How to insert multiple postmeta values with one query?
  49. ‘Organize Series Plugin’ as muti author feature
  50. WordPress custom taxonomy not showing
  51. Mass SQL WordPress Meta Key deletion
  52. Date format – Meta Box plugin
  53. Getting taxonomy images to display on single-post with their terms
  54. Where to populate custom terms in custom taxonomy in plugin?
  55. get meta value from database by post id
  56. Default taxonomy template in plugin, override in theme
  57. How to remove bulk actions from custom post type
  58. How to select a paragraph other than the 1st to be the post’s excerpt?
  59. How can I concatenate variables to search results title? [closed]
  60. wp_insert_term() doesnt insert a term
  61. Renaming Custom Taxonomy Values
  62. Smarter navigation plugin and custom taxonomies
  63. Remember the Meta Value With Radio Buttons
  64. Installed Forca Theme, wonder how I can alter Post editing screen
  65. WooCommerce custom taxonomy as meta?
  66. Link Posts to External URL
  67. Rename existing cpt and taxonomy with new textdomain
  68. how to create hierachial taxonomy and manage under single post type?
  69. Get product categories and add them to a custom taxonomy
  70. Help to Create a Simple Plugin to make a post
  71. Adding category base to url in custom post giving 404?
  72. Display posts by alphabetical order
  73. get_post_meta shortcode returns empty field
  74. Add an action based on custom post meta field
  75. how to auto random increment for post view
  76. How to securely controlling data without keeping it in postmeta?
  77. Performance considerations – postmeta table versus new table for custom posts with foreign keys?
  78. Why is my custom taxonomy image not displaying?
  79. Show custom taxonomy in theme
  80. Taxonomy Category Icon on index page
  81. Get only selected custom taxonomy
  82. Get value from an input field and pass into update_meta_data as $meta_value
  83. How to get post that has non zero or greater than zero meta value
  84. Delete postmeta when uninstall/delete plugin
  85. How can I make my plugin display custom post meta data on the front end?
  86. Add “selected” class to custom taxonomy dropdown search
  87. “Tree view” for wp_dropdown_categories() markup
  88. Is saving multiple options or saving multiple items in one option better?
  89. Show similar category portfolio items?
  90. Storing values in Post Meta vs new tables
  91. Is there a way to add a custom input field for every taxonomy term in WP post editor?
  92. Award points if a specific custom taxonomy is selected – Cubepoints
  93. Get post id in Post Page within Wp-admin
  94. Output plugin post like system count [closed]
  95. ACF Taxonomy Object term Null [closed]
  96. getting image alt text via ACF plugin in WordPress [closed]
  97. Display Custom Post Type and Custom Taxonomy Data on Front End Using Only a Plugin
  98. Force post update with React
  99. How do I know if an archive correspond to a custom post type taxonomy?
  100. How to make a page setting translatable in theme?
Categories plugins Tags custom-taxonomy, plugins, post-meta
Shortcode and WP query using category attributes
add_action in wp_head accessible from class

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