Skip Navigation

[Resolved] I want to add data from a custom post type (Artists) to a Woocommerce Archive.

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by mikeB-8 9 years, 5 months ago.

Assisted by: Caridad.

Author
Posts
#255034

I have Artwork products in Woocommerce organized by Category which = the Artists name.
I have CPT Artists (from WP-Types) which have Post names that are the same as Woocommerce Categories.

I want customize the Woocommerce Product Archive pages to feature some data from my Artist CPT
but I can't figure out how to relate them.

I basically expect that on a product category archive where the category name is "Pablo Picasso" I could have a view that got it's Category filter value provided by the current page title? So "Pablo Picasso" Archive Page would pass to the shortcode or url parameter and display data from Artist CPT "Pablo Picasso"

Is this possible with Views?

If not, could you perhaps suggest a way for me to link these.
I realize I could male a custom hard coded template for EACH artist, but that defeats the purpose of the whole CMS approach.

Any ideas?

Thanks.

#255251

You can do this from the actual template file in the theme, it could be category.php or similar, adding a call to render a view:

<?php 
$title = single_cat_title( '', false );
echo do_shortcode( '[wpv-view name="Name of view" artist="' . $title . '"]' );
?>

The actual filename and title code may change from theme to theme.

Please let me know if you are satisfied with my reply and any other questions you may have.

Regards,
Caridad

#258456

Hi,
Thank you.
This is very helpful and allowed me to output the results of a View onto a Woocommerce Category Archive page.

However: I think I may have misunderstood a fundamental aspect of Views here.
My View is intended to output a SINGLE Artist Post Type's data, not a list of them.
I thought I just had to limit the output to 1.

I do not want to return a list of my Custom Post Types, I want the data from ONE Custom Post Type entry. Now I am reading that for single items one needs to use a Content Template instead of a View. But content templates do not seem to allow a filter , much less a filter based on a shortcode.

Please advise. Is there a way to do this setup and output the info from ONE entry rather than a list?

Thanks.
By the way, this came in a 4am my time, and without knowing, I found myself lying awake thinking about this problem at the same time. I should have gotten up and worked on it. 🙂

#258709

Hi,
Well maybe I got that wrong.
My view DOES display only the one matching artist.

I am using Headway Templating system. I thought I could use the custom code block to add this php in, but it always end up with an unmatched output. ie, the most recent artist's data shows on all pages.

However, when I customized the Woocommerce Archive Page and put your php code into the template directly, it works as expected.

Thank you SO MUCH.
~Mike

#258908

Actually you need to use a "Content Template" to display a single post of any type.

Here it is explained the main differences between a "View" and a "Content Template":
https://toolset.com/documentation/user-guides/views/

Please let me know if you are satisfied with my reply and any other questions you may have.

Regards,
Caridad

#259127

Hm, I think you meant this article.
https://toolset.com/faq/whats-the-difference-between-a-view-and-a-view-template/

I'm not sure why, but this is working. probably because there is only one possible matching result for this particular relationship.

Thanks.

The forum ‘Types Community Support’ is closed to new topics and replies.

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