Hello everyone,
I need a solution to a common wordpress problem that is not well documented online(to my knowledge) and the solution being repeated is not ideal, ie: adding "page 2 etc" to the end of a title. To me this is not a unique title, it's a continuance of the same title.
My site: As you may have guessed this site has multi-page posts via <!-nextpage-> and the content of these posts is about the same general subject but is not identical. If the title was widgets page two might be about painting widgets and page three about storing widgets for the winter. Same general subject, very different content on each section.
Google strongly suggests that a canonical tag
not point back to the first section of these multi-page posts: [
googlewebmastercentral.blogspot.ca...] and so each section needs a truly unique title, and that is where the problem is with wordpress
By default: Wordpress simply assigns the same title to all parts of a multi-page post and assigns a canonical back to the first section. I've resolved the canonical issue, and now I need truly unique titles for each section, adding "page 2", "page 3" etc doesn't cut it.
Custom field: I'd like to create a custom field for each post that would contain the title for each individual section and, if one exists, this title would replace the page <title> on page 2 onwards.
Best effort: The simplest method, in my opinion, would be to tap into the "the_title" filter via functions.php as follows
add_filter( 'the_title', 'multi_post_title', 10, 2 );
function multi_post_title( $title, $post_id )
{
if( $new_title = get_post_meta( $post_id, 'custom_field_name', true ) )
{
return $new_title;
}
return $title;
}
I am at a loss, however, about how to set up that custom field so that it contains multiple entries, one for each section of a multi-page post, and to have a function choose the correct one. Any insight on having each section of a multi-page post receive it's own truly unique title would be much appreciated. To be honest this should already be a core funtion within wordpress, but it's not. Thanks.