Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.
Please copy the code given here: https://pastebin.com/mXRhxBd6 and paste it inside your theme’s functions.php file.
It will strip your title’s length to 60 characters.
Hope this helps. Let us know if you need any further assistance.
Thank you.
But I want to run a function if rank math meta title has certain lengths such as 63 Characters. Is there any conditional tags to do this?
Hello,
Thank you for getting in touch with us.
Could you please share more details on what condition do you want to apply if the length is 63 characters, so that we can assist you properly?
Looking for your update. We will love to assist you.
Thank you.
I am looking this conditional tag’s Codes:
add_filter('the_title', function ($title) {
If rank math meta title contains 63 characters then
return do_shortcode('[mbv name="app-short-title"]');
}
return $title;
});
Hello,
Since our SEO titles, most times make use of the variables and those only get translated on the frontend it might not be possible to get the actual length if not running the code in the frontend.
Having said that, if you are not using variables for that you can do this with the following check:
$seo_title = get_post_meta(get_queried_object_id(), 'rank_math_title', true);
if ( strlen($seo_title) < 63 ) {
// Run the code that you want
}
If you really need to get the title that is displayed fully on the frontend you can use the function wp_title() to get the full title and then check the length of that.
Hope this helps solve your issues.
Don’t hesitate to get in touch if you have any other questions.
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.