I want to do something very simple but I'm stuck finding where in WordPress I need to perform this.
When someone on my WordPress site visits a blog post page I want the title in the blog post to replaced the title of the page.
I think I can do this with the wp_title filter hook?
I thought about something like the following :-
add_filter('wp_title', 'filter_pagetitle');
function filter_pagetitle($title) {
$the_post_id = get_the_ID();
$the_post_data = get_post($the_post_id);
$title = $the_post_data->post_title;
return $title;
}
However I am a bit lost as to where I put this, I thought it would need to be in loop-single.php as I want this to apply only to single pages, but I have also seen that this needs to be in functions.php within my theme?
Any help would be appreciated :-)
Rich