Hello,
Thank you so much for getting in touch.
Just to make sure that I am getting this right. Do you wish to insert the parent category title in the title of its associated sub-category?
If so, at the moment, we currently don’t have that feature.
If you are referring to the actual page title, you would need to create a shortcode for it, and if you are referring to the SEO title, then a custom variable is what you need.
Hope that helps and please do not hesitate to let us know if you need my assistance with anything else.
yes, you’re right, I wish to insert the parent category title in the title of its associated sub-category.
You guys do it in the breadcrumbs, why not in the meta title and description?
Hello,
The breadcrumbs are supposed to show the path that leads to the page and that’s why the parent category title is included while the title of the categories should be unique. If you want to show the parent category in the SEO title then you can include the same in the page title of the category.
You can also use the following filter to create a new variable:
add_action('rank_math/vars/register_extra_replacements', function () {
rank_math_register_var_replacement(
'parent',
[
'name' => esc_html__('Parent Category', 'rank-math'),
'description' => esc_html__('Name of Parent', 'rank-math'),
'variable' => 'parent',
'example' => parent_callback(),
],
'parent_callback'
);
});
function parent_callback()
{
$cat = get_category(get_queried_object_id()); // get the object for the catid
$parentcat = $cat->category_parent;
return get_cat_name($parentcat);
}
Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Once done, you can use the %parent%
variable to add the title of the parent category to the meta title of the subcategories.
Hope that helps. Let us know if you need any other assistance.
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.