Change <title> for a specific post by ID

Let's change the page title for a specific post by ID in WordPress using document_title_part filter hook.</p>

add_filter( 'document_title_parts', function($title) {
    if ( get_the_ID() == 32 ) {
        $title['title'] = 'Your updated title here';
    }
} );

Leave a Reply

Your email address will not be published. Required fields are marked *