2

In my child theme's functions.php file, I'm trying to change a page's title tag:

function custom_title() {
    return "Page Title";
}
add_filter( 'wp_head', 'custom_title', 9999 );

The code above is not changing the page's default title. What am I doing wrong?

1

Check this out

function custom_title($title_parts) {
    $title_parts['title'] = "Page Title";
    return $title_parts;
}
add_filter( 'document_title_parts', 'custom_title' );

In custom_title, $title_parts contains 'title', 'page' (the pagination), 'tagline' (the slogan you specified) and 'site'. Set "title" the way you like.

  • Thank you! This did what I wanted to do, NOT wp_head(). – GTS Joe May 28 '16 at 6:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.