Yoast / wordpress-seo

Yoast SEO for WordPress
https://yoast.com/wordpress/plugins/seo/
Other
1.77k stars 893 forks source link

Template variable for a parent product category %%ct_product_cat%% fails to be outputted on sub product category pages #12211

Open Pcosta88 opened 5 years ago

Pcosta88 commented 5 years ago

Is your feature request related to a problem? Please describe.

Users want to output the parent product category in the title of a sub product category

Describe the solution you'd like

Users must manually enter in the parent product category. We should provide template variable for a parent product category.

Note, the parent title variable does not work: https://kb.yoast.com/kb/yoast-wordpress-seo-titles-metas-template-variables/.

why you think the feature request is something we should consider for the Yoast SEO plugins?

Improve UX and Content SEO

Pcosta88 commented 5 years ago

related https://github.com/Yoast/wordpress-seo/issues/12156

jonoalderson commented 5 years ago

Hmm. I think this one is slightly different to #12156. If I'm reading this right, the challenge is:

"I have a product called 'red sock' in WooCommerce, categorised in 'footwear'. I want the title to be Red sock > Footwear | Brandname".

In this case, %%parent_title%% won't correctly return 'Footwear', but that's expected behaviour - this isn't a 'child post', it's a product in a category - so %%parent_title%% isn't populated.

We have %%ct_product_cat%% for WooCommerce categories; does that solve it?

Pcosta88 commented 5 years ago

@jono-alderson Nope.

1. Add a product category as a subcategory. In this example: Hats

screen shot 2019-02-14 at 8 16 39 am

2. Add the %%ct_product_cat%% template variable

screen shot 2019-02-14 at 8 16 17 am

3.See that the parent product category fails to be outputted

screen shot 2019-02-14 at 8 16 26 am
jonoalderson commented 5 years ago

Well, that should work, I think! Bug!

monbauza commented 5 years ago

I think the %%ct_product_cat%% is expected to output all the categories assigned to a product. Since we'd like to output the name of the parent product category in the title of the child category, a template variable like %%parent_title%% should be used in this case. However, this variable seems to work only with pages not with taxonomies.

A similar feature request was submitted some time ago https://github.com/Yoast/wordpress-seo/issues/6527 but it was closed at that time.

monbauza commented 5 years ago

Please inform the customer of conversation # 486296 when this conversation has been closed.

mayada-ibrahim commented 5 years ago

Please inform the customer of conversation # 551730 when this conversation has been closed.

michaelbriantina commented 3 years ago

https://wordpress.org/support/topic/display-parent-category-on-sub-category-page/

maybellyne commented 1 year ago

+1 https://wordpress.org/support/topic/primary-category-not-shown-in-meta-title/

jan-caerels commented 5 months ago

+1 Sadly still not fixed, I've had this issue since 2020. For products, I set the SEO title something like (loosely translated): %%title%% - %%ct_product_cat%% | %%website title%%

This however outputs not the primary category, but ALL the categories that the product is assigned to. Imagine a (tile) product named "Box grey", being in the categories "floor tiles", "ceramic floor tiles", "concrete look tiles", "terrace tiles", "ceramic terrace tiles". The output of %%ct_product_cat%% is all those categories.

josevarghese commented 5 months ago

Hi @jan-caerels

As mentioned in our help center for the snippet variables, %%ct_product_cat%% will output all the categories that are selected for the product page separated by commas.. So the result you have noticed is an expected result.

This issue is about outputting the parent category name when the %%ct_product_cat%% is used on a child product's category page and not on the product page.