I've been trying to change the title in a dynamic page without any luck.
What I did is I created two page-templates from where I load items (occasions) from an external database. In one page-template I load the single-page occasion:
<?php include 'Occasions-files/single.php';?>
And the second page-template I load an overview of the occasions:
<?php include 'Occasions-files/file.php';?>
Now the title is default from the SEO plugin. I've tried All-in-One SEO as well as Yoast SEO but can't seem to overwrite the title. What I want is to change the title from single.php into the occasion name but leave all the other pages to the SEO plugin.
I'm not quite experienced with this and I'm not sure where to start. For testing purpose I've tried to put test manually before the get_header, then it shows the manually added title, but my header is messed up. When I put the title after the get_header, it loads the header ok but the title isn't shown and is still default
<title>test</title>
<?php get_header(); ?>
Also, I've tried to add a filter (to the functions.php) but this was also without any results or maybe I have no clue on how to insert it..?
function custom_title_function($custom_title) {
$custom_title['title'] = "Test Title";
return $custom_title; }
add_filter( 'document_title_parts', 'custom_title_function' );
Anyone has an idea on how to resolve this? Many thanks in advanced!