Skip Navigation

[Resolved] Generating Views views and pages or CPTs automatically, in bulk

This support ticket is created 4 years, 12 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by Vane 4 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1399565

Hi,

the website is a complex directory website.
I may have around some hundred custom taxonomy values and also custom fields.
I'd like to create hundreds or thousands of views, setting some view data automatically.
Let's say I have 100+ business sectors and I'd like to create a view for every each sector, that means I have to do it one by one, manually, which is not too time-saving.
In reality I want to further refine views by further filtering sectors by other custom taxonomy or field values, meaning I might really have thousands of views.
These number of views preset by the website, but further filtering by users should also be enabled and set.

- Will this work with so many views (1000+) ?
- Can I generate them automatically ? ( I'm sick of doing them manually 🙂 )
- I also would like to automatically create pages or specific custom post types and insert these views in them, so one CPT instance would contain like companies related to Fashion industry (business sector), pre-filtered by custom field values (like only Manufacturers) and user may further filter the result by eg. Countries (or whatever).
So the view name is like "Fashion-Manufacturer" and the CPT's title where this view is inserted is like "Manufacturers in the Fashion industry".
- Do you have a better solution, workaround ?

Thank you!

#1399891

Hi, rather than creating all these Views, it would make more sense to create one View with Query Filter(s) that accept shortcode attributes. Then you can pass values into the View's Query Filters by applying different shortcode attributes. This technique is called passing arguments into Views, and is explained in more detail here:
https://toolset.com/documentation/user-guides/passing-arguments-to-views/

As far as creating posts automatically, that's not something Toolset is designed to accomplish. You can import posts using a CSV file if that would speed things up. In theory you could add a View shortcode in the post content area of the CSV file, and use different shortcode attributes to predefine some filters. Or you could create a Content Template that includes a View and apply that template to multiple posts.

#1401537

Hi Christian,

I'm sorry but the concept described on linked page is not clear for me yet.

Let's say I have :
1 custom taxonomy ( CT_1)
3 custom fields ( 2 post, 1 term; CF_P_1, CF_P_2, CF_T_1 )
every each of this 4 has 10 values, which means 10 000 combinations.
I'd like to create as few views as possible and as few pages as possible and I want to allow visitors to modifiy 2 filters at most
( let's say CF_P_2 and CF_P_3 ), so the other 2 (CT_1, CF_P_1) should be pre-set, in every each combination ( in our example: 10*10= 100 )

I hope I don't have to have 10 000 pages defined which contains all the filters set in different combinations.

My use case is like a Woocommerce webshop when I want to use product category pages AND brand pages combined,
so when I have 10 product categories and 10 brands, I need to display somehow all the 100 combinations,
either with static or dynamic content (preferably dynamic obviously),
so I need filtered page for Nike shoes and Adidas shirts etc., with ability for further user filtering eg. by size and color.

So i f you can direct me toward such a doc page and/or to demo and/or to sample views / custom templates where this is solved, I'd appreciate it.

Re: generating pages/posts automatically: you write it is out of Toolset's scope.
If there's no other solution for my use case, Toolset might consider to move it to its scope.
Toolset has a bunch of features which are much less useful than this - this is how I think.

Thank you!

#1402161

3 custom fields ( 2 post, 1 term; CF_P_1, CF_P_2, CF_T_1 )
Let me clarify something here. You cannot filter a View of posts by a custom term field. You could only filter a View of terms by a custom term field. So in a custom search View of posts, a term field filter isn't supported. If you want to include a taxonomy term filter in a View of posts that is fine, but you cannot also hook up a term field filter in the same View and have the taxonomy term filter respond based on your selection in the term field filter.

I hope I don't have to have 10 000 pages defined which contains all the filters set in different combinations.
No, the solution I was describing does not require many pages but it does require the use of URL parameters. For example, you will create one View and place it on some custom Page. Then you can create links to that page that utilize different URL parameters to set the different filter values (or leave the filters empty). For example:

<em><u>hidden link</u></em>

The View's filters will respond to these URL parameters so that "Nike" is selected, as well as the two other example custom field values shown.

If URL parameters are not acceptable, then you need a way to create very custom URLs. WordPress does not automatically generate archive URLs using custom field values, nor does it create separate taxonomy term combination archives ("/nike/red" for example, where nike and red are terms in separate taxonomies) so this requires custom code, or a CSV import process to generate all the necessary Pages. Another option might be a post generation plugin like FakerPress, which you can use to automate the process of creating Pages. Regardless of how those posts and URLs are generated, you would need a way to parse the URL and determine the proper shortcode attributes, then pass them into the View's shortcode in your page or page template:

[wpv-view name="your-view-name" ct="nike" cfp1="1234" cfp2="6789"]

The Query Filter in the View would have to be setup to respond to shortcode attributes instead of URL parameters.

#1408101

Thank you!