I am using Yoast SEO plugin on a site. Right now if a Post's Title is left empty in the metabox for a post, then the Title tag will output in this format...

%%title%% %%page%% %%sep%% %%sitename%%

Now if that same post does have a custom title text saved in it's meta field...then it shows only the text from the meta.

What I need to do is show %%sitename%% after the titlte text no matter what!

So even a title that is saved as This is my title the output on the HTML page will be...
This is my title - SITENAME

Does anyone know how to do this?

1 Answer 1


You can use the wpseo_title filter to read the tag for your site title after WPSEO creates it, and if it's not there, add it on.

add_filter( 'wpseo_title', 'wpse137502_wpseo_title' );
function wpse137502_wpseo_title( $title ) {
    $site_title = get_bloginfo( 'name' );
    if ( ! strpos( $title, $site_title ) ) {
        $title .= " | " . $site_title;
    return $title;
  • Thank you for this. I wish Yoast had a checkbox option to always include the title template, when using custom titles (which essentially override the template).
    – jwinn
    Nov 4, 2015 at 5:30
  • Indeed. But the idea for the override is complete control. It shouldn't STILL add in stuff. Nov 4, 2015 at 13:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.