Hello,
Thank you for contacting Rank Math and bringing your concern to our attention.
Sine you are using your custom search page, Rank Math is not able to deduct it. Please use the following code and add it inside your current theme’s function.php
file to get your job done:
add_filter( 'rank_math/frontend/title', function( $title ) {
$sname = get_bloginfo( 'name' );
$getstring = htmlspecialchars($_GET["ad_title"]);
$title = $getstring. " - " .$sname;
return $title;
});
Hope that helps. Thank you and please don’t hesitate to contact us if you need further assistance.
Hello @ankit , I have added the code mentioned above , it’s working fine with search term as a title on search page. But, the issue is , it’s removing all other titles of all post types and home page.
Hello,
Please replace the code with the code given below:
add_filter( 'rank_math/frontend/title', function( $title ) {
$sname = get_bloginfo( 'name' );
$getstring = htmlspecialchars($_GET["ad_title"]);
if ($getstring) {
$title = $getstring. " - " .$sname;
return $title;
}
return $title;
});
This should fix the issue. Let us know if you need any further assistance.
Thanks.
Wonderful, it works!
Thankyou RankMath team! Your support is wonderful!
Hello,
Glad that helped.
Please feel free to reach out to us again in case you need any other assistance.
We are here to help.
Thank you.