Skip Navigation

[Resolved] Trying to generate a link to a product on other posts based on shared tax term.

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.

This topic contains 5 replies, has 2 voices.

Last updated by Pandora Pang 6 years, 2 months ago.

Assigned support staff: Beda.

Author
Posts
#299517
model_screenshot.jpg

I am trying to: finish resolving a previous support thread. When I try to respond to the support thread I created, it tells me to login but I just logged in. That, however, is not the problem I'm trying to solve. That is just why I'm posting the same problem twice.

This is what I'm trying to figure out:

I am trying to: figure out if the following is possible—I use WooCommerce so I have products. I also have 2 custom taxonomies—brand and model. I have a blog that I also use. Brand and model taxonomies are used with both products and blog entries. I'd like to make it so that there is a link to the brand's page on my site and a link to the product page the blog post is about at the end of each blog post. Is that possible? If not, might it be possible using custom fields?

To be clear, I'm attaching a small screenshot. This is created by Types and shows at the end of every post. I changed it from "link" to "text" because they were linking to the taxonomy archives. Instead I want the brand to link to the brand's page on my site. And I want the model to link to the product page for that model.

Each term in the model taxonomy is applied to only one product. It may be applied to several posts (posts about that product) but never to more than one product. So is using the model taxonomy a viable option? That would save me from having to add a custom field to every single product and post.

Thanks for your help. I've been digging through the documentation and I'm just not sure if I'm on an impossible mission.

If you want to see the old support thread, this is the link: https://toolset.com/forums/topic/trying-to-generate-a-link-to-a-product-on-other-posts-based-on-shared-tax-term/

#299795

Thank you for contacting us here in the Support Forum

The issue with the forum not allowing you to reply (you need to be logged in) is a cache issue, and usually it's solved by re-loading the same page (while already logged in)

Anyway, as Waqas mentioned, you'll need to find a way to "relate" the blog posts with the related product (which is also a post type)

The Idea of taxonomies is, that once you "clic" on a link leading to taxonomy "A", ALL items belonging to that taxonomy are listed, in a archive page.

As Waqas explains:
"If Category X is used with Products A, B and C.,
the View can actually query Products Only, but will return all products under Category X -
>unless there's a particular identification available at hand.<"

With custom Fields you could achieve this "unique identification".
You could also create a Child Post that belongs to your Product, which would be your
"Blog Post about that Product"
You can add more then one Child Post per Product
(Brand and model child posts, in your case )

You can then filter in the View by "Post relationship filter", and Output in the Loop a link to it only.
You insert the view wherever you need it.

If this does not describe accurately the issue you mention, please don't hesitate to get back at me!

Please let me know if you have further questions regarding the issue mentioned in this Thread
and let me know if the above solution works for you, I look forward to your reply!

Thank you

#299828
query_error_screenshot.jpg

Hi and thank you for your response. I understand what you're saying about taxonomy not really being the way to go because it links to taxonomy archives.

After reading your response, I did go in and make another attempt. But I have some more questions as a result.

If I were to use custom fields to achieve this "unique identification" what would those need to be? If I had a custom field for model, how does that make a connection to that's model's product page? I understand that my view could elect to show the link instead of the name, but how would it know what link to show?

Or would I ALSO need to create child posts for my product? When I tried that approach, I was told that posts and products weren't hierarchical and therefore wouldn't display. I attached a screenshot of this because this is where I got stuck.

I'm also unclear as to whether you made 2 separate suggestions (custom fields or child/parents posts) or whether those need to be combined.

Thanks for your help and your patience.

#300085
View - filter products by Custom Field
Custom Select Field.png
Custom Field Group.png

Thanks for the Details

If I understand that correctly you're using default Posts and Products, which are not hierarchical.
For hierarchical approach, you wold need to create new Custom Post TypeS with Types Plugin.

Anyway, lets set that aside for now.

I think you can easily achieve your goal following as below mentioned:

1. Create (i.e.) a Select Custom field, with the options you need, once for Brands, once for Models
(Each a sigle Custom Select Field, with as many options your brands or models have/need)

2. Assign those fields to Posts and Products

3. When creating posts and products, choose the correct value from the field
(as example product A has brand XX and model XY)

4. In a view list Products, filtered by Custom Field Brand (i.e.) and choose to filter by (i.e.) number, that is equal to the value of the option you gave in your Custom Select Field for the desired Option

5. Output only the title with link in that view, and insert the view into your post or product.

To be more detailed, if you filtered for Products, Custom Field "Brands", value "1", that link would lead from where you insert the View to :
Product with that exact set Brand (lets say brand "Vivid" has value "1" in the Custom field settings)

Note that you can list and filter as man Post types you want and use as many Filters you want

I attached a view screenshots to explain that.

If this does not describe accurately the goal you try to achieve you mention, please don't hesitate to ask for specifications or more information.

Perhaps, in case I do not understand your query correctly, access to your site could help to see it closer and workout a solution from a tangible base.

Thank you for your patience

#300322
views_link_goal.jpg

Thanks for the clear instructions. But if I did what you suggest, would that require me to create a view for every single model?

And I'm happy to give you access to the site, but how do I do that without giving everyone with access to this forum my login info?

I'm not sure if we quite understand each other or not. I attached another screenshot that hopefully helps clarify. Sorry to be such a pain. But thanks for your help!

#300333

I got it to work! Thanks for your help!