Adding sitename to all SEO titles

#151463
  • Resolved Laura Elizabeth
    Rank Math free

    I have recently switched from AIOSEO to Rank Math. Previously all my SEO titles were set to add a separator and Site Name to the end.

    I can’t figure out how to do this in Rank Math.

    I have entered the following as default for all posts and pages:

    %title% %sep% %sitename%

    However, my hundreds of existing posts and pages have a custom “SEO title”, and so do not use this default. The SEO titles from AIOSEO are intact, but I can’t figure out how to keep the “| Site Name” part.

    (I realize that the ability is there to add a separator and site name at the page/post level, but I need to have this applied site-wide.)

    I’ve looked through all the settings, but can’t find where I can add this as a default to the SEO meta. Please advise.

Viewing 11 replies - 1 through 11 (of 11 total)
  • Anas
    Rank Math business

    Hello,

    Thank you for contacting Rank Math, and sorry for any inconvenience caused.

    You can use %seo_title% %sep% %sitename% to display the SEO Title along with the separator and sitename.

    To set this please navigate to Rank Math > Title & Meta > Posts > Single Post Title > Change and Save.

    I hope this helps. Looking forward to helping you.

    Hi Anas,

    Thanks for the quick reply.

    Unfortunately, this does’t work.

    Rank Math > Title & Meta > Posts > Single Post Title only applies if there is no SEO title set at the post level.

    Because all my posts/pages already have a set SEO title, the default in the field you specify isn’t relevant.

    So I need to find another way to add %sep% %sitename% to my existing SEO titles, site wide. (Titles set in the SEO meta box at the page/post level).

    Hello,

    In that case, you may need to use the filter below to update your titles:

    /**
     * Filter to change the page title.
     * 
     * @param string $title
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
    $title = RankMath\Post::get_meta( 'title', get_seo_content_id() );
    	return $title;
    });
    

    This would return the title meta you have set in the global settings. Please let us know if this helps you.

    Thank you.

    Hi Michael,

    We tried adding the filter, but it broke the site, as there is no get_seo_content_id() function.

    Is get_seo_content_id() the right function?

    Hello,

    I modified the code to append the sitename to all posts/pages on your title, please try this:

    
    /**
     * Use the Description from Global Setting, if the description is missing in the Post metabox
     */
    add_filter( 'rank_math/frontend/title', function( $title ) {
    	
     global $post;
     $title = RankMath\Post::get_meta( 'title', $post->ID );
    
     if ( $title ) {
    	 $title = $title ." - ". get_bloginfo('name');
    	  return $title;
     }
    
     return $title;
    });
    

    Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.

    Hi Michael,

    This worked, thank you.

    Is there somewhere I can submit a feature request? I really think this should be added to the global page and post settings:

    – the ability to globally append static values, or variables, to the SEO meta titles

    This feature was available in AIOSEO, so it’s a bit of a problem for those migrating to Rank Math. And while your solution works, it means that the character counter for SEO meta titles is now inaccurate. (If you have a further fix for that, let me know!)

    Thanks again for your help,
    Laura

    Hi Laura,

    I am glad to hear this worked for you.

    I will be happy to pass your request to our dev team for consideration.

    If this is something we are able to implement, we will be sure to let you know.

    Do you have any further questions?

    We are here to assist.

    Thank you

    I think I’m good for now.

    Thanks for the quick and helpful support!

    Laura.

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

    Hi again!

    The filter function you gave me is working to append ” | SiteName ” to our %seo_titles%.
    (We changed the ” _ ” in the code to ” | ” )

    BUT, when there is NO SEO title set, and Rank Math generates the default (which in this case is %title% %sep% %sitename%, it is now using the wrong separator.

    Rank Math is outputting a – instead of | , even though we set the default separator is | .

    Not sure why, the filter function is altering the default separator, but only in cases where there is no SEO title.

    Hello,

    Thank you for the follow-up, and sorry for the delay.

    Since you have already changed the default separator to |, could you please also check if the hyphen - is also applying in the post’s source code when you publish it? Or it’s only showing in the edit snippet part.

    If the issue still persists, Assuming you are using the latest version of all the plugins and the themes (please update if not yet), could you please also clear your website’s cache?

    I hope that helps. Thank you, and looking forward to your update.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 11 replies - 1 through 11 (of 11 total)

The ticket ‘Adding sitename to all SEO titles’ is closed to new replies.