Archived topic
Site Title Added To Posts - How Do I Stop It?
11 replies · Started by steven on April 11, 2022
Hey!
I've noticed on quite a few of my posts that the site title is appended to my post titles. This is screwing up the SEO on these posts and I would like to stop it.
I'm not using YOAST Seo. I do use a meta title plugin - but that doesn't seem to help. Google reads the title tag (that the theme displays from the Wordpress post) and displays that - but with the site title appended. It won't read the meta title from the meta plugin. (I use the plugin to specify the meta description, which sometimes works)
Is there any way to stop the generate press theme from appending the site title to post titles.
(I have examples. I tried to change them this morning but even if I change the post title, it keeps adding the site title after)
Hi there,
where are you seeing this ? Can you share a link so I can see it ?
Check my site title VS title on view page source
Look at the actual title I want
EDIT: The link to view page source is blocked. If you view the page source, and search for title, you will see that it's added my site title to the end.
There are lots of them.
Try adding this PHP Snippet:
add_filter( 'document_title_parts', function( $title ) {
unset( $title['site'] );
return $title;
}, 10, 1 );
Sorry David, I note you actually mentioned this before on one of my previous topics but I fixed the problem myself so I didn't see it.
Could you just refresh my memory where and how to add the snippet? I will bookmark the answer this time!
No probs - this doc explains how to add PHP:
https://docs.generatepress.com/article/adding-php/
TLDR: If you have a Child Theme installed: add the code to the functions.php, if you do not then install the Code Snippets plugin, add a new Snippet and add the code there.
I installed and activated it. Added the snippet and activated it.
Didn't work.
Pages still append site title.
Do you still have that other plugin installed ? If so disable that, and then clear any plugin/server caches.
To note; I tested the snippet on a clean GP install and it does still work, so we need to eliminate whats interfering with it.
I uninstalled the meta titles plugin and sure enough, the problem has gone.
I prefer to use 0 plugins to be honest, so the less the better. But I would really like to write my own meta descriptions.
However this is more important so happy to move on from this one..There are unfortunately other problems I'm having which I hope I can get some guidance on.
Thanks very much for your help!
You could try changing the snippet i provided to:
add_filter( 'document_title_parts', function( $title ) {
unset( $title['site'] );
return $title;
}, 999, 1 );
The only change is increasing the priority 10 to 999 - this just means the code get fired later, maybe after whatever that plugin is doing. As long as the plugin isn't hijacking that filter it should work...
I've unstalled the plugin and it works.
I'd rather have less plugins anyway.
Thanks man.
OK glad to be of help!