Home › Forums › ACF PRO › Delete WP Title and use ACF Title › Reply To: Delete WP Title and use ACF Title
This take a couple of steps, first hiding the title WP title field. I see that you’re also not using the WP editor so that makes it a bit easier
add_action('admin_head', 'hide_wp_title_input');
function hide_wp_title_input() {
$screen = get_current_screen();
if ($screen->id != 'your-custom-post-type') {
return;
}
?>
<style type="text/css">
#post-body-content {
display: none;
}
</style>
<?php
}
next, update the post to use the custom title field for the post title
// you'll want to rename the function
add_action('acf/save_post', 'save_post_type_post'), 20); // fires after ACF
function save_post_type_post($post_id) {
$post_type = get_post_type($post_id);
if ($post_type != 'your-custom-post_type') {
return;
}
$post_title = get_field('your_custom_field', $post_id);
$post_name = sanitize_title($post_title);
$post = array(
'ID' => $post_id,
'post_name' => $post_name,
'post_title' => $post_title
);
wp_update_post($post);
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.