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:
- updating one custom meta field only
- Check for custom field value in different post type than current one and do something
- what is the correct way to compare dates in a WP query_posts meta_query
- Advanced search form with filters for custom taxonomies and custom fields
- Custom field values deleted when trashing custom post type
- How to get all custom fields of any post type
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- How do I Paginate Search Results for Custom Post Types?
- How Can I save multiple records in same meta key?
- Detect meta value changes when post is updated (post_updated)
- Search everything (posts, pages, tags, cpt, meta)
- WordPress Admin Panel search posts with custom post meta values along with title
- How to get source of custom meta image?
- Displaying Meta Box Image
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Create a random unique 6 digit number as custom field for custom post type
- query posts and custom post type with meta key
- how to interconnect custom post types?
- List all images from a single post meta value
- Populate Custom Fields in a Custom Post Type?
- Meta Key Value in current-user-only loop
- How to check if user meta field is empty in conditional else statement
- How to implement a Google map store locator
- How do I create an archive page as a including metadata?
- Posting to a Custom Post Type from front end – user generated content
- Update Post Meta for a logged in user
- A better way to add a meta box to custom post types
- Two Custom Post Types Many to Many Relationship
- get_post_meta not working on publishing
- How do I set all of a particular post meta to a value within the custom post type I’m in?
- Custom fields (wp_post_meta) vs Custom Table for large amount of data
- Importing Data from a Non-WordPress database, into WP
- Custom fields for custom post type
- Check if post with same meta value exists
- Submitting Custom Post Types with custom fields from Front-end form
- create custom meta box with default value
- delete_post_meta() for whole CPT / multiple posts?
- How to get specific post meta by title or id
- copy images from custom field to another custom field
- How to show custom field on specific custom post type posts only when filled
- Cannot obtain custom meta information
- How can I output WPAlchemy repeating fields meta values in my page template?
- How to call a post’s metadata in shortcode.php?
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- Add a class to post_class if more than one post shares same meta_value_num
- Add a meta field to the list of results for a custom post type
- Empty meta-box returns publishdate if no value is set?
- Filter search posts by post meta?
- Custom fields for post or terms which don’t update on post update
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- Custom Post Type meta data getting deleted on bulk editing taxonomies
- How to use multiple Meta Field from CPT as Post permalink
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to keep custom post type related information
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Show posts from WP Custom Post Type selected from a field in a metabox
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Where is get_post_meta value located?
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- Add more custom fields when creating a new custom post type
- How do I extract the contents of a CPT’s custom field for all posts?
- Delete custom post type metadata without deleting the post in admin area
- How can I get the $key / $value pairs of custom fields that were added via 3rd party plugins or themes?
- How to add post reference field to a plugin?
- Advanced search form with filters for custom taxonomies and custom fields
- Querying meta values within an array
- Get post with multiple meta keys and value
- Custom Post Type Data in Sidebar widgets?
- Hide custom post type field from author?
- Creating Photo Gallery System with Custom Post Type
- Set post title from two meta fields
- Trying to save custom post type from frontend partially working
- Custom Taxonomy order by Custom Field
- How can I include meta box content when searching?
- How to break meta values into different items and avoid duplicates?
- Custom Post Type Navigation on Custom Field
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- Filter custom posts using auto populated dropdown selectors
- What WordPress function to use to get meta value by using meta keys?
- filter custom post in rest api with custom function
- Update database from Quick Edit according to Checkbox state of Custom Post Type
- Is there any way to add a “custom field” to the CPT archive page?
- don’t publish custom post type post if a meta data field isn’t valid
- WebP Fallback for Inline Background Image in Style Attribute
- Do posts, pages and / or custom post type objects have unique ID numbers or can there be multiple objects with the same IDs?
- Editor / Add Media: Is it possible to only allow galleries?
- How do I show my containing my custom field ONLY if there is a set value on that custom field? [closed]
- Adding an extra parameter [string] to my posts’ permalink?
- Add Extra Category Field to CPT Categories
- Query posts by current ACF meta key value on single page as related posts
- Use WP_query to match post types based on custom field values
- Post Filtered by Custom Field Value
- Stored meta from attachment, video length?
- Can’t pick up a field created with Advanced Custom Fields
- Post content is cleared when updating
- Create action running on trashed_post hook to modify post_meta value
- pre_get_posts causes Custom Posts appear under ‘Pages’ menu