Skip Navigation

[Resolved] Create template that shows only 1 product category per row looping through each

This support ticket is created 6 years, 7 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 6 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#906486

Tell us what you are trying to do?

I'm new to this tool and have a PHP background, so everything being shortcodes is a bit confusing right now while also learning your tool. We're trying to get something setup to display a different product category on each row for the WooCommerce Shop page. I've created a custom template that's needed for this client, so I don't need Toolset layouts. However, what I need to know is the syntax or procedure for an output that would display something similar to the old site: shop.visualworkplace.com

Right now, I'm working in staging on: staging1.shop.visualworkplace.com

Is there any documentation that you are following?

What's on your site, which isn't quite addressing this issue.

Is there a similar example that we can see?

shop.visualworkplace.com

What is the link to your site?

staging1.shop.visualworkplace.com

I can grant you access to staging, if you'd like. We're looking to keep shop functions in the sidebar as I currently have it setup, and header and footer as it's currently setup. I've created a custom theme to do this and assigned a generic woocommerce(); function to the theme by adding support for it in functions.php. The old site uses Divi, which is trash, and also the Divi Injector, which is buggy. I'm looking for something clean like I have setup in staging, only for each row being a product category with the title. For example, Online Training as the title for the first with the output row of product_training as the slug, then next loop would be Books with the slug of books, etc.

Any help is greatly appreciated. I've been experimenting, been through the docs, but this is very confusing for someone who comes from a traditional background of doing a Bootstrap to WordPress conversion. Thanks!

Derek Neuts

#906784

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screen Shot 2018-05-31 at 12.48.57.png

Hi Derek

A quick note on creating templates with Views.

You'll understand the Template Hierarchy that determines which PHP template is used by WordPress at a given URL.

Views templates let non-coders modify such templates, but not by making any changes to the PHP templates themselves, but by hooking into the_content(); which those templates use to output the post body and replacing it with... whatever the users includes in their Views Content Templates created in the back-end.

Shortcodes are effectively a way to run PHP within post content (which isn't directly possible in WP). When WP encounters a shortcode it runs the corresponding PHP function which should return a string and replaces the shortcode with that string in the content.

That's how we can add dynamic content (e.g. a custom field value) to the post output.

In terms of your question about a custom product archive.

I'm not sure when you say "I've created a custom template that's needed for this client" whether you mean you've created a custom PHP template, or whether you have created a Views Content Template?

In any case, on an archive page you can specify certain ordering options (see screenshot), but grouping by product category isn't one of them.

You may find it easier given your background to write the required custom query directly in your PHP template, but if you wanted to do something like this in Toolset you would

1. create a View to query product categories
2. create a second, nested, View to display products filtered by the product category of the outer View
3. you'll need to insert this second View in the Loop Output section of the first View

You can then either insert this outer View into a standard page which can be your "shop" page.

Or if you want it to appear at the WC shop URL you would have to create a custom archive (at Toolset > WordPress Archives) for products and add the View in the wpv-items-found section but not within the wpv-loop tags, which should be empty (so that the normal archive contents are not output).

Make sure you are following the directions about using the Toolset WooCommerce Views add-on: https://toolset.com/documentation/user-guides/getting-started-woocommerce-views/