Using a custom field as the title
-
Hello, I have a custom post type called “shop-items”, and inside it 3 custom fields, one of them is “itme-name”, I would like to use it instaed of the title in the display page on the wp-adming.
I have the following function in my functions.php file:
add_filter(‘title_save_pre’, ‘save_title’);
function save_title() {
if ($_POST[‘post_type’] == ‘shop-items’) :
return $_POST[‘item-name’];
endif;
return “error”;
}but it doesnt work, I have checked the post data when I save/post a new shop-item, and there is no header named ‘item-name’, instead what gets the value I put in this field is ‘fields[field_541898e2373f4]’, and the 2 other custom fields also looks something like that. I have tried changing the $_POST[‘item-name’] to $_POST[‘fields[field_541898e2373f4]’] but it just return blank (“”). What do I do here to make it work.
Thanks in advance.
- The topic ‘Using a custom field as the title’ is closed to new replies.