Hello,
I have updated the sensitive data as requested. Can you please check further?
Thank you.
Hi Fred,
Thanks for getting in touch with us.
You can use this filter to register your own variable and show it in the drop down at WordPress Dashboard > Rank Math > Titles & Meta >
/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
*/add_action( 'rank_math/vars/register_extra_replacements', function(){
rank_math_register_var_replacement(
'custom_variable_slug',
[
'name' => esc_html__( 'Custom variable name.', 'rank-math' ),
'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
'variable' => 'custom_variable_slug',
'example' => 'custom_variable_callback()',
],
'custom_variable_callback()'
);
});
We are assuming you know a bit of PHP to make it work.
If not, please let us know so our team can help you further.
Thank you.
hey, can you answer me pls. im want use your plugin.
Hi, thanks for answer. i did something in admin panel everything seems okey but when i publish article or new category i dont see on title new veriable.
admin place: http://prntscr.com/r3og1r – http://prntscr.com/r3okov
but i dont see nothing on title or desc. after publish. http://prntscr.com/r3ohsk
example code i used in functions.php:
/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
*/add_action( 'rank_math/vars/register_extra_replacements', function(){
rank_math_register_var_replacement(
'years',
[
'name' => esc_html__( 'Custom variable name.', 'rank-math' ),
'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
'variable' => 'years',
'example' => '2020-2021',
],
'custom_variable_callback()'
);
});
Hi Fred,
Thank you for getting back to us.
You need to modify the callback on your code and add the return type as shown below:
/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
*/
add_action( 'rank_math/vars/register_extra_replacements', function(){
rank_math_register_var_replacement(
'years',
[
'name' => esc_html__( 'Custom variable name.', 'rank-math' ),
'description' => esc_html__( 'Custom variable description.', 'rank-math' ),
'variable' => 'years',
'example' => '2020-2021',
],
'my_variable_callback'
);
});
function my_variable_callback(){
return '2020';
}
I hope this info helps.
Hello! yes it has helped many thanks. Well I want to add more than one variable. Need to write the same code one after the other? for example, i want add 4-5 another veriable.
So what kind of encoding i need for 4-5 different variables? such as %years% = 2020-2021,% examyear% = 2020% life% = 2023.
Hi Fred,
As much as we would love to offer customized solution to each and every user we have, it just isn’t possible for a small company like ours with limited resources.
Unfortunately, you will need to make further changes on your own. We have given you the basic template of making it work.
If you need help with anything else, please open a new support ticket here so we can help
We are always here for assistance.