-
Hello,
I´m trying to add custom values to titles by using this https://rankmath.com/kb/filters-hooks-api-developer/#add-extra-variables . So I added this code: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()'
);});
function custom_variable_callback()
{
return "test";
}to the functions.php in WordPress, “Custom variable name.” is shown in the dropdown menu so I add it and then it displays error on the page where it should display the value. The error is:
Fatal error: Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, function "custom_variable_callback()" not found or invalid function name. (the whole error is in sensitive data box). What is wrong with that? Where do I make a mistake? pls help.Thank you a lot.
If there would be a way to use classic WordPress function it would be great as well. I have custom plugins that uses wp shortcodes, but it does not work with Rank Math.
The ticket ‘24. Add Extra Variables to the Rank Math Dropdown – error’ is closed to new replies.