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:
- Query all posts where a meta key does not exist
- Can the Next/Prev Post links be ordered by menu order or by a meta key?
- 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
- Meta query with boolean true/false value
- Get post with multiple meta keys and value
- Correctly delete posts with meta and attachments [duplicate]
- Storing revisions of metadata for custom post type
- Custom field values deleted when trashing custom post type
- How to get all custom fields of any post type
- Update CPT meta data using REST API
- Admin Area Custom Type Search By Meta Fields Without Title & Content
- Echo all meta keys of a custom-post TYPE
- Custom Post type – how to get checkbox to update meta field to null
- How can I filter posts by post_parent in the admin?
- How do I Paginate Search Results for Custom Post Types?
- Ordering posts having multiple post-meta date fields
- Custom Post Type with Input fields to seperate table on database.
- 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?
- Post metadata deletes itself
- How to create a mini directory in WordPress?
- How Can I save multiple records in same meta key?
- Get all posts from custom post type and insert in select input as metabox
- Detect meta value changes when post is updated (post_updated)
- Search everything (posts, pages, tags, cpt, meta)
- Permalinks using event date (year & month) instead of publication date
- I can’t set meta_key in my custom post type query
- Grossly inefficient wordpress loops!
- Compare 3 custom fields and sort by oldest
- How Do I Use WP_Query to Run This Database Query as Search Result?
- WordPress Admin Panel search posts with custom post meta values along with title
- Creating a custom post type upon registration
- 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
- Reason action hook won’t work with update_post_meta from frontend form? Alternative?
- Can’t sort order of wp_query with 2 meta keys
- Showing Meta Data for Custom Post Types?
- How to get source of custom meta image?
- Having trouble with custom post type / meta box
- Query for posts from any post type but only add instock products
- How can I include meta box content when searching?
- update a post meta from a single table cell TablePress
- update custom post type meta from a shortcode
- Custom Meta Boxes – Nonce Issue – Move to trash issue
- Displaying Meta Box Image
- Custom post type category not displaying in custom post type
- How to make custom post meta wp_editor translatable?
- Automatically adding meta data to posts or multiple query help
- How to keep a check box in custom meta box for custom post type checked by default for add new post?
- How to add multiple featured image in meta box in post editor?
- Show metabox in custom-post-template depending on taxonomy term?
- ACF Upload Image in repeater from front-end with custom form? – add_post_meta()
- update_post_meta() whenever custom post type is updated
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Trigger “unsaved changes” dialog for custom post meta changes
- Using date stored as custom field to filter posts displayed in admin
- Conditionally Query Custom Post Types by Post Meta for Blog Home Page?
- Displaying custom posts only if custom meta box’s date is not expired
- Displaying Metabox value (custom post type taxonomy)
- How do I sort a custom post type admin column using two meta keys?
- Add Post Url to Manage Edit Screen
- How to best delete orphan wp_postmeta
- How can I display my custom metaboxes on a custom post template?
- Display all custom post type posts and order them by an optional meta_key
- Meta Box Only in CPT Edit Page, Not in Add New
- Change the contents of a dropdown through the admin panel?
- Advanced search form with filters for custom taxonomies and custom fields
- Retrieve post data via WPDB class
- Top 30 Songs using Custom Post Type
- Advice Needed for Post Meta Database Efficiency
- fetch meta fields inside a widget
- Querying meta values within an array
- Create action running on trashed_post hook to modify post_meta value
- Post AND page parameter for WP function
- Random meta field from specific custom post type
- Custom post type – update_meta not working
- why get_post_meta is returning 0?
- Custom Post Type meta value is being saved in array, instead of just the string (as value)
- Save post_parent in a custom post type
- Custom Form Data save after Login User
- How to display Author Profile based on Custom field value
- Use a Variable in update_post_meta as the $meta_key
- Automatically add custom taxonomy when meta value gets to a set number or beyond
- Display a list of posts whose meta field values are equal to the ID of the post being viewed?
- Update an existing post in a custom post type
- Check for custom field value in different post type than current one and do something
- Changing to different post type maintains the redirection?
- Post Meta for Custom Post Types
- How do I add the “orange counter” next to a Custom Post Type?
- getEntityRecords/useEntityRecords: How to use CPT metadata?
- I am having a problem with fetching product data in the Gutenberg block editor
- CPT meta values intermittently return empty
- Quering a post object based on another related post object
- rest_api_init is not getting invoked inside a Class
- Normal Posts and Custom Posts with Date Query
- Optimizing storage of Post Meta Entries