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

Display a list of posts whose meta field values are equal to the ID of the post being viewed?

For the author single page

$query = new WP_Query(array(
    'post_type' => 'books',
    'meta_key' => 'author',
    'meta_value' => get_the_ID() // assuming you're inside the loop
));

while($query->have_posts()) {
    $query->the_post();
    the_title();
}
wp_reset_query();

For the books archive page

// assuming you're inside the loop
$author = get_post(get_post_meta(get_the_ID(), 'author', true));

Related Posts:

  1. updating one custom meta field only
  2. Check for custom field value in different post type than current one and do something
  3. what is the correct way to compare dates in a WP query_posts meta_query
  4. Advanced search form with filters for custom taxonomies and custom fields
  5. Custom field values deleted when trashing custom post type
  6. How to get all custom fields of any post type
  7. Admin Area Custom Type Search By Meta Fields Without Title & Content
  8. How do I Paginate Search Results for Custom Post Types?
  9. How Can I save multiple records in same meta key?
  10. Detect meta value changes when post is updated (post_updated)
  11. Search everything (posts, pages, tags, cpt, meta)
  12. WordPress Admin Panel search posts with custom post meta values along with title
  13. How to get source of custom meta image?
  14. Displaying Meta Box Image
  15. ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
  16. Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
  17. Create a random unique 6 digit number as custom field for custom post type
  18. query posts and custom post type with meta key
  19. how to interconnect custom post types?
  20. List all images from a single post meta value
  21. Populate Custom Fields in a Custom Post Type?
  22. Meta Key Value in current-user-only loop
  23. How to check if user meta field is empty in conditional else statement
  24. How to implement a Google map store locator
  25. How do I create an archive page as a including metadata?
  26. Posting to a Custom Post Type from front end – user generated content
  27. Update Post Meta for a logged in user
  28. A better way to add a meta box to custom post types
  29. Two Custom Post Types Many to Many Relationship
  30. get_post_meta not working on publishing
  31. How do I set all of a particular post meta to a value within the custom post type I’m in?
  32. Custom fields (wp_post_meta) vs Custom Table for large amount of data
  33. Importing Data from a Non-WordPress database, into WP
  34. Custom fields for custom post type
  35. Check if post with same meta value exists
  36. Submitting Custom Post Types with custom fields from Front-end form
  37. create custom meta box with default value
  38. delete_post_meta() for whole CPT / multiple posts?
  39. How to get specific post meta by title or id
  40. copy images from custom field to another custom field
  41. How to show custom field on specific custom post type posts only when filled
  42. Cannot obtain custom meta information
  43. How can I output WPAlchemy repeating fields meta values in my page template?
  44. How to call a post’s metadata in shortcode.php?
  45. delete duplicate meta_value with same post_id
  46. Search CPT Title AND Meta
  47. Add a class to post_class if more than one post shares same meta_value_num
  48. Add a meta field to the list of results for a custom post type
  49. Empty meta-box returns publishdate if no value is set?
  50. Filter search posts by post meta?
  51. Custom fields for post or terms which don’t update on post update
  52. Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
  53. Custom Post Type meta data getting deleted on bulk editing taxonomies
  54. How to use multiple Meta Field from CPT as Post permalink
  55. Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
  56. How to keep custom post type related information
  57. How can I add a meta[] to my custom post type and search by term with the Rest API?
  58. Show posts from WP Custom Post Type selected from a field in a metabox
  59. Creating an archive page or simple template to list all values of a custom field of specific post type listing
  60. Where is get_post_meta value located?
  61. Custom meta fields not showing up in WP_Response Object via custom endpoint
  62. How to Disable option of meta field if that option is selected for any other post in custom post type?
  63. Add more custom fields when creating a new custom post type
  64. How do I extract the contents of a CPT’s custom field for all posts?
  65. Delete custom post type metadata without deleting the post in admin area
  66. How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
  67. How to add post reference field to a plugin?
  68. Advanced search form with filters for custom taxonomies and custom fields
  69. Querying meta values within an array
  70. Show Post columns to specific users on condition
  71. Displaying Custom Fields from Custom Post Types [closed]
  72. Change picture attachment meta of all occurrences of a picture
  73. Unknown Post Meta Records
  74. Displaying posts inside table having issues
  75. Get Previous Post based on Custom Field Name, for Custom Post Type
  76. Get meta values from parent post and save in child post
  77. Custom post types – meta_query: search lesson which starts sooner
  78. Saving custom post types post_meta over REST-API fails
  79. Sql Update CPT from publish to draft and particular custom field
  80. How to properly get the wp_postmeta.meta_value of a custom post type in specifics?
  81. Custom post types & Pages hierarchy – Error 404
  82. Ordering Post by Meta Key (Not Working)
  83. Post Filtered by Custom Field Value
  84. How do I get all authors posts of a custom post type outside loop
  85. Adding a Section for Visitors
  86. Error when moving custom post type to bin
  87. add action save post type and update post meta woocommerce
  88. Automatic Set Category For A Custom Post Type
  89. How to link custom field of two custom post types?
  90. get_post_meta not working with variable as a post_id for dynamically get the postid
  91. Custom Function to redirect singular post if specific meta field is empty
  92. How to replicate data storage and querying using WordPress. Custom posts/fields or Custom db tables?
  93. Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
  94. CPT – Custom Text fields point to new url permalinks
  95. Autofill advanced custom field with user data
  96. Confused about where to store my data
  97. Using Orderby and meta_value to order natural/alphanumerical
  98. Advanced search form with multiple custom fields
  99. filter rest api post by a acf filed
  100. How to get post detail based on URL of the post
Categories custom-post-types Tags custom-field, custom-post-types, meta-value, post-meta
How to change the CSS in one file?
WP_Query – meta fields numeric

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