I would simply filter the_title so that it outputs the appropriate custom-field data for your custom post type:
<?php
function theme_slug_filter_the_title( $title ) {
global $post;
if ( 'employee' == get_post_type( $post ) ) {
$custom = ( get_post_custom( $post->ID ) ? get_post_custom( $post->ID ) : false );
$custom_title = ( isset( $custom['name'][0] ) ? $custom['name'][0] : '(Name Not Entered)' );
return $custom_title;
} else {
return $title;
}
}
add_filter( 'the_title', 'theme_slug_filter_the_title' );
?>
This will replace the post title with the value for custom field “name” for your custom post type. If no “name” is entered, it returns “(Name Not Entered)”.
(Of course, you’ll need to replace the values for get_post_type() and $custom['name'], as appropriate.)
Related Posts:
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- Advanced search form with filters for custom taxonomies and custom fields
- Meta query with boolean true/false value
- Custom field values deleted when trashing custom post type
- How to get all custom fields of any post type
- Custom Post type – how to get checkbox to update meta field to null
- How do I Paginate Search Results for Custom Post Types?
- How do I remove all the metaboxes for a custom post type?
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- Gutenberg how to make attribute to save to meta
- How to programmatically create a connection with [Plugin: Posts 2 Posts] on cpt publish?
- WordPress Admin Panel search posts with custom post meta values along with title
- How to Update post status using meta data in Custom post TYpe
- Rest Api v2 orderby meta_key in custom post type
- bulk Update post_meta with default values
- How can I include meta box content when searching?
- Add Post Url to Manage Edit Screen
- Display all custom post type posts and order them by an optional meta_key
- How can I get_post_meta() in the most efficient way?
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- how to interconnect custom post types?
- Custom Post Status Transition Issues With Get Post Meta
- List all images from a single post meta value
- orderby in custom WP Query does not work
- Show the same Article Available in Other Categories
- how to delete all users and posts based on ‘user_meta’?
- Meta Key Value in current-user-only loop
- How to set YouTube video as featured image?
- Custom Post Types. Are there any disadvantages/advantages in using a plugin to develop them?
- How to implement a Google map store locator
- Widget: Custom Post Type Post Listing Dropdown on Admin Side
- Update Post Meta for a logged in user
- How to duplicate entire custom post type
- Two Custom Post Types Many to Many Relationship
- get_post_meta not working on publishing
- get_post_meta returning no value in custom post type alert email
- WordPress request fiter order by related post’s post_title
- Update database from Quick Edit according to Checkbox state of Custom Post Type
- Getting thumbnails of a custom posts featured images in a page-templates metabox
- Remove Post Custom Meta Box
- Show future events based on custom field AND order by date
- If Post Meta Equals Current Title Conditional Advanced Custom Fields
- create custom meta box with default value
- Issue on Working with Metabox – Checkbox to enable Sale Items
- delete_post_meta() for whole CPT / multiple posts?
- How to move a post to different post type with all meta data?
- Why do I have to press the “Update” button twice to save my meta box values?
- how to show records that don’t have custom meta value
- WP API Response does not show my registered metadata
- How to detect that the save_post hook is calling the callback associated to the current edit post page only
- Problem with adding custom post type meta to header by plugin
- How to call a post’s metadata in shortcode.php?
- Echo custom post meta from options array
- Value of post meta dropdown is not showing in WordPress
- Get all metadata for a given custom post type
- WP_Meta_Query object with conditionals
- Trying to write shortcode with get_post_meta but isn’t working
- Advanced custom field – posted fields from custom post type
- delete duplicate meta_value with same post_id
- Search CPT Title AND Meta
- updating one custom meta field only
- Add a class to post_class if more than one post shares same meta_value_num
- Function to return values from metabox
- Add a meta field to the list of results for a custom post type
- Custom fields for post or terms which don’t update on post update
- Should I use a custom taxonomy or custom post type for grouping a list of panels associated with a group of tests?
- Add a form in every post and save data in post meta
- How to use multiple Meta Field from CPT as Post permalink
- 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
- Peepso: Add extra data field (custom post meta) to postbox
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Change picture attachment meta of all occurrences of a picture
- Unknown Post Meta Records
- Get Previous Post based on Custom Field Name, for Custom Post Type
- Get meta values from parent post and save in child post
- Saving custom post types post_meta over REST-API fails
- How do I get all authors posts of a custom post type outside loop
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- How to get post detail based on URL of the post
- Custom post type meta fields missing on save_post_type
- Linking posts together with Advanced Custom Fields “both ways”
- Stripe multiple transactions
- How to get Current week and current date record wp query
- Edit is changing my custom’s post type parent id
- Complex strcuture as CPT or taxonomy for use in woocommerce product variations [closed]
- How to add post reference field to a plugin?
- WordPress custom post type
- Edit post meta direct from post.php?
- Custom Post Type meta oembed html output resulting in WSoD
- Timetable of Custom Meta Data using Custom Post Type and Custom Taxonomy
- Change the contents of a dropdown through the admin panel?
- fetch meta fields inside a widget
- Random meta field from specific custom post type
- Custom post type – update_meta not working
- Use a Variable in update_post_meta as the $meta_key
- Post Meta for Custom Post Types
- getEntityRecords/useEntityRecords: How to use CPT metadata?
- CPT meta values intermittently return empty