Missing Site Name

#183038
  • Resolved Niklas We
    Rank Math free

    Hello,

    I had already opened a ticket but marked it as resolved even though it is not unfortunately.

    The problem I still have is that after switching from AIO SEO to RankMath the site name (%sitename%) does not appear anymore in the single page title. Before I switched to rankmath it worked fine and the site title appeared at the end of every single seo-page-title. However, now it is gone even though I have set the settings correctly (at least this is what I assume).

    One of you suggested the following code

    add_action( 'rank_math/frontend/title', function( $title ) {
    	global $post;
    	if(is_singular('page')){
    		$ptitle = RankMath\Helper::get_settings( "titles.pt_{$post->post_type}_title" );
    		$title = RankMath\Helper::replace_vars($ptitle, $post);
    		return $title;
    	}
    });

    However, this does remove all the individual seo titles which I have set manually for every single page.

    Since I have more than 1700 pages, I can not add the site title manually to each page. However, when I create a new page, then the site title is added automatically.

    I have sent you a temporary link, so maybe you have any help for me.

    I do not want to annoy you with my problem. I just would like to know whether there is any way to get the site title added to every single page. If not, I am fine with it.

    Best Regards,

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello,

    Thanks for contacting us.

    Please copy the code given below and paste it into your theme’s/child theme’s functions.php file:

    add_action( 'rank_math/frontend/title', function( $generated ) {
    	if ( ! is_page() ) {
    		return $generated;
    	}
    	global $post;
    	$title = RankMath\Helper::get_settings( "titles.pt_page_title" );
    	$title = RankMath\Helper::replace_vars( $title, $post );
    	return empty( $title ) ? $generated : $title;
    });

    This will use the title set in the WP Dashboard > Rank Math > Titles & Meta > Pages for all your pages. So you will only have to change it once and it will appear on all your pages.

    Hope this helps. Let us know if you need any further assistance.

    Niklas We
    Rank Math free

    Hello,

    thanks for your reply but the code still removes the SEO Title which I have set individually for every page. The code replaces the SEO Title with the page title.

    It a bit weird and I am very grateful for your help but I hope you understand what I mean.

    Hello,

    Thanks for getting back. Sorry for the delay and any inconvenience that might have been caused due to that.

    If you just want to add the name of your site to the title that you have set for your pages then you can the code given below:

    add_action( 'rank_math/frontend/title', function( $generated ) {
    	if ( ! is_page() ) {
    		return $generated;
    	}
    	global $post;
    	$title = $generated." - PrudentWater";
    	$title = RankMath\Helper::replace_vars( $title, $post );
    	return empty( $title ) ? $generated : $title;
    });

    Hope this helps. Let us know if you need any further assistance.

    Niklas We
    Rank Math free

    Hello, it works but the site name does not appear in the SEO preview snippet when I edit a single page. Does the site name appear in the SEO title in a google search list?

    Regards,

    Niclas

    Hello,

    Thanks for getting back.

    You will not see these changes in the SEO meta box while editing a single page. This code applies the changes to your page’s source code in the frontend.

    And as Google crawls the site and fetches the details from the metadata of your page so these changes will also be reflected in the search results.

    Hope this helps. Let us know if you need any further assistance.

    Niklas We
    Rank Math free

    Hello,

    alright, many thanks for your help and all the information!

    Regards,

    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.

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

You must be logged in to reply to this ticket.