Skip Navigation

[Resolved] How can I display WooCommerce products on posts that share categories or tags?

This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 6 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#579193

Hello,

I am having trouble figuring out how I would display WooCommerce products in a view loop is the products and the posts have the same categories or tags. I'd like to know how to do it with both categories or tags because we use them in various ways.

So, let's say I am writing an article, and this article is about Spanish cooking. Let's say the article is tagged with the same tags as some of the products OR uses a couple of categories that the products are also using. How can I create a view that loops through only the products that are using the same tags or categories as the posts?

I hope this makes sense.

I found the setting where I can filter by taxonomy with "the same page where this view is shown", however, I am struggling with no posts showing. Will this not work if the post category is the same name as the product category, or the tags match?

Please let me know if you have any questions.

Thanks!

#579277

Dear Michael,

In your case, I suggest you try with a nested view:
1) Parent view list terms of "categories", filter by:
Taxonomy term filter
Taxonomy is set by the page where this View is inserted
and display below child view

2) Child view list "Product" posts, filter by:
Select posts with taxonomy:
Categories set by the parent Taxonomy View
And display "Product" post information.

#580830

Luo,

I tried this, and it does not work.

Is this because post categories are not the same taxonomy as product categories?

If this is the case, how can I get certain products to be related to a post when that post has the same post category name as the product has product category?

Unless I am doing this wrong, but I followed all of your directions.

Please advise.

#580831

Luo,

Just so you know, I also just tried to create a custom taxonomy called "Related Products". I associated it to both Posts and Products. Then, I added the "Select posts with taxonomy: Related Products set by the parent Taxonomy View" to the child view, and "Taxonomy is set by the page where this View is inserted" in the parent view.

No products display on the post where I put the parent view.

-----------

EDIT: this worked ... I had to make sure the new custom taxonomy was selected in the "Content Selection" of the parent view.

So, I am unable to use the default categories to connect posts and products ... I had to create a custom taxonomy that can be associated to both post types.

Thanks!!

#580940

Yes, you are right, the solution I provided above only works for "a custom taxonomy that can be associated to both post types":
https://toolset.com/forums/topic/how-can-i-display-woocommerce-products-on-posts-that-share-categories-or-tags/#post-579277

If you need "two taxonomies associated to two different post types", you can also pass the term name value as view's shortcode attribute, for example:
1) Parent view list terms of taxonomy "Post categories", filter by:
Taxonomy term filter
Taxonomy is set by the page where this View is inserted
and display below child view, and pass term name as shortcode attribute "wpvcategory" to below child view

2) Child view list "Product" posts, filter by:
Select posts with taxonomy:
Product Categories name in one of those set by the View shortcode attribute wpvcategory
eg. [wpv-view name="view-name" wpvcategory="xxxx"]

see our document:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/
section "Controlling the filter with shortcode attributes"

and
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/
Value set by View shortcode attribute

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.