NO BUG: Related product from the same level category

Hi,

On the product subpage, I want to display products that are in the same category as the product being viewed.

Assuming the category hierarchy looks like this:

Clothing > T-shirts > PRO T-shirt

i want to display only products from the PRO T-shirt category.

Thats my query setup (it doesn’t work):

https://imgur.com/a/YfRPByS

Hi pedronx,
Thanks so much for your report!

Your taxonomy query can’t work since {post_terms_product_cat} doesn’t return IDs. Please try this:

Best regards,
timmse

Thank You!

unfortunately the query is not limited to this one “PRO T-shirt” last category, it only shows everything that is also in the parent category “T-shirts”

Thats the rest of my setup: https://imgur.com/a/rYMqBKd

Hm, I can’t replicate it in my setup unless the product is assigned to both the parent and the child category. If it’s only assigned to the child, it works fine on my end.

Your category assignments may be different, so you may need a custom function to achieve the desired result. It’s hard to say without seeing the whole setup. Feel free to send temporary login credentials and a link to this thread using the email address associated with your account so we can take a closer look.

Thanks for the login credentials, but it’s basically what I already mentioned. The products are assigned to T-Shirts (Parent) and Pro T-Shirt (Child). To make this work, they should be assigned only to Pro T-Shirt (don’t worry, they still show up in the T-Shirts archive).

As already mentioned, you can also create a custom PHP function (ChatGPT is pretty good for this if you’re not familiar with PHP) that returns only the child term and omits the parent term, based on your specific requirements.

Thank You very much!