Hello,
Thank you for contacting Rank Math today.
The only viable we could think that can be used for this would be to create a shortcode that would accept a parameter which would be the variable name and then parse it.
You can then parse those using the helper function replace_vars() from our plugin to output the value of the variables.
Hope this helps point you in the right direction.
Don’t hesitate to get in touch if you have any other questions.
First of all, thanks for your reply.
Can you share a code to create that shortcode?
Hello,
Below is an example that creates the shortcode [rm_title] for the title. You would need to create similar custom functions for other variables:
add_shortcode('rm_title', 'rm_shortcode_title');
function rm_shortcode_title(){
$obj = get_queried_object();
if(is_single()){
$title =get_post_meta($obj->ID, 'rank_math_title', true);
return RankMath\Helper::replace_vars($title);
}
if(is_tax()){
$title = get_term_meta($obj->term_id, 'rank_math_title', true);
return RankMath\Helper::replace_vars($title);
}
}
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.