Hello,
I’m trying to avoid using an SEO plugin and would like to use ACF for our <title> and <meta name=”description”>.
I was able to figure out the Meta Description by adding some code to header.php… but I can’t figure out the <title> part.
I’d like to replace the automatically generated <title> if the ACF field is filled out.
Is this even possible? If so can someone point me in the right direction.
Thanks!
Thanks for the reply! I tried that solution but it ended up changing my h1 title as well.
In case anyone was wondering, I got this working by adding the following code to my functions.php
add_filter('document_title_parts', 'replace_page_title', 10);
function replace_page_title($title) {
if( get_field('meta_title')) {
$title['title'] = get_field('meta_title');
}
return $title;
}