You can hook into the_title()
to alter the output.
In functions.php paste this:
function my_change_title( $title, $post_id ) {
$custom_title = get_post_meta($post_id, 'mycustomvalue', true);
if( isset($custom_title) && $custom_title == 'apple' )
return $custom_title;
return $title;
}
add_filter('the_title', 'my_change_title', 10, 2);
In your template, you can just use <?php the_title(); ?>
To use your custom value in your template:
<?php $custom_value = get_post_meta(get_the_ID(), 'mycustomvalue', true); ?>
<?php if( isset($custom_value) && $custom_value == "apple" ) : ?>
Do something
<?php endif; ?>
Related Posts:
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Individual Widgets per Page
- Is it safe to store a user setting you don’t want the user to ever modify as a user option?
- Add custom fields to search
- How to add add_meta_box to specific Page Template?
- How to get users by a custom field / by user meta data?
- Auto sort the wp-admin post list by a meta key
- extend Meta Box / Document Panel
- Add multiple images to a page sidebar
- getEntityRecord without knowing the post type
- Get updated meta data after save_post hook
- Add custom field to image editor
- Show User Their Password
- Metabox nonce PHP notice
- TinyMCE in Custom Metabox not loaded after upgrading from WP 3.1.4 to WP 3.2
- How to reload the role specific registration form on validation errors?
- How to break meta values into different items and avoid duplicates?
- ajax delete value from custom field array
- How can I sort get_users() by any value (last_name, user defined fields and more)
- Custom field for default gallery
- After moving my site from a dev subdomain, to root, all my custom meta data is gone
- How can I query on the year part of a complete date in a custom field?
- Currency (price) formating on custom fields
- Gravity Forms: Create fields programmatically
- WordPress Custom Field Should be Unique. Is it possible?
- all tincymce’s switch when updating page after changing from html to text in custom metabox
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- How to display Meta Field Value?
- What is the cleanest way to extract custom variables from a post
- Add source URL from Feed WordPress (Syndication) plugin to a custom field in post editor
- List custom taxonomy terms from custom field
- How do I create a column in Users list and display user data from custom registration field
- How to add posts through CSV or excel file in a PHP file
- Merge Multiple Custom Fields into one New Custom Field for Searching
- Is there a better way to list all database terms alphabetically?
- Can’t display errors in attachment_fields_to_save
- Customizing WP user profile with custom fields
- Custom Field 101
- When creating a metabox do you have to create DB fields for the data?
- Using abs() with custom field in orderby statement
- Best filter to use for modifying custom fields on a post?
- Changed PHP handler to DSO – weird custom fields problem [closed]
- How do I query the title (or handle?) of post meta fieldset (created with Simple Fields Plugin)
- Is it preferable to use custom code to create metaboxes instead of plugins (such as ACF) and if so why? [closed]
- Function that replaces the image in the absence of the post meta
- Is there a way to set default custom fields when creating a new post?
- Add custom column for custom field
- ul list with only as many li’s as filled custom fields
- Is there a way to dump all registered sidebar/widget?
- How to hide post meta
- ACF Plugin How to make the customer add more fields in the post?
- custom field in admin columns
- How to sort by custom field value?
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- get_post_meta returns 0
- Populate wordpress menu with link to custom field value (file download)
- Custom field bug in WordPress 3.2
- Users uploaded image and matching an id or taxonomy
- Adding data to User profile
- How can I change author of posts to the value of one of the custom field of the posts?
- How to save multiple values with same meta_key, each value linked to another tag id
- Let any visitors delete a post if they know Id nr & password?
- What WordPress “technology” would I use if I wanted subscribers to be able to mark pages with characteristics and notes?
- Is it possible to add Term Meta Fields to a WooCommerce Attribute?
- update a custom field with the value of another existing custom field
- Post meta data not showing in frontend, until hitting ‘update’ button
- a lot of custom fields
- Hide custom fields by user’s role
- Ordering posts by custom fields (Date)
- update meta field value after
- PHP and Shortcode Combination
- Retrieving Advanced Custom Field within Shortcode Function [closed]
- How to properly get popular Posts by multiple Values
- Custom fields and auto save
- Save values generated via API as custom meta fields
- Query Custom Fields in Searchform
- Make custom user_meta as permalink for post
- Creating Structured Documents (books) in WordPress?
- Get custom fields when hover link of post
- WP Query multiple select form – meta_query help
- update_post_meta not working in action hook
- Custom field in a shortcode?
- Group pages by custom field values
- Convert many posts from having a specific meta_key to use a post_format
- Custom fields: my custom checkbox area doesn’t seem to work
- Exclude empty fields from custom field calculation (Average)
- How to create Parent-Child relation for custom fields?
- How to check if custom field exists in this widget query
- display loop only if a post meta data exist
- How do i output images from URL’s added to the same custom field key
- Add Custom field under the post title [closed]
- Check if a field is capitalized?
- Filter Query Post by Custom Fields(by date)
- Can’t sort custom column on user.php by number / meta_value_num?
- Need to call this php function inside a modal window from text widget
- Add CSS class to posts with certain meta key
- Best way for managing images of ads banners
- Crop custom image size vs actual size
- Multiple permalinks for a single post from custom field
- Search for meta_query does not return any result if combined with title