-
I’m trying to create custom variable (%cars%).
My code is…
add_action('rank_math/vars/register_extra_replacements', function() { rank_math_register_var_replacement( array( 'variable' => 'cars' ), array( 'name' => 'Total cars', 'description' => 'Total cars', 'example' => count_cars() ), 'count_cars'); });
I’m getting this error:
Warning: preg_match() expects parameter 2 to be string, array given in /var/www/vhosts/cars.com/httpdocs/cars.com/wp-content/plugins/seo-by-rank-math/includes/replace-variables/class-manager.php on line 108
Ok, I know first parameter of function is string
rank_math_register_var_replacement(string, array, string);
But, if I define first variable like a string, I get an error:
Fatal error: Uncaught InvalidArgumentException: $variable is required for the cars variable.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The ticket ‘Error creating custom variable’ is closed to new replies.