Hello,
Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for the delay and for any inconvenience this issue may have caused you.
The %category%
variable is only used for post types.
In this case, you may try using the %term%
or %customterm(taxonomy-name)%
variables on your meta title.
Here’s a link for more information about variables:
https://rankmath.com/kb/variables-in-seo-title-description/
Hope that helps.
Thank you.
Thank you for your response.
I have added the variables you mention but they don’t work.
However, I tried the following code and it did work. I share it in case any user might be interested.
/**
* Action: 'rank_math/vars/register_extra_replacements' - Allows adding extra variables.
* Snippet to register variable that will return the number of posts in the current term
*/
add_action('rank_math/vars/register_extra_replacements', function () {
rank_math_register_var_replacement(
'portfolio_category',
[
'name' => esc_html__('Category Portfolio', 'rank-math'),
'description' => esc_html__('Category Portfolio Description', 'rank-math'),
'variable' => 'portfolio_category',
'example' => portfolio_category_callback(),
],
'portfolio_category_callback'
);
});
function portfolio_category_callback()
{
$term = get_queried_object();
$idPost=$term->ID;
$current_term = get_the_terms( $idPost, 'portfolio_category' );
return isset($current_term) ? $current_term[0]->name : '';
}
Best regards
Hello,
Thank you for the update.
We appreciate you sharing the filter to register the taxonomy as a variable.
If you have any other concerns, please don’t hesitate to contact us anytime to assist you further.
Looking forward to helping you.
Thank you.