Skip Navigation

[Resolved] Include multiple custom post types in view query filter

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
- 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/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by aaronW-4 1 year ago.

Assisted by: Waqar.

Author
Posts
#2576977

I received help on the following post:
https://toolset.com/forums/topic/repeatable-fields-inside-of-view_template-on-page/

Is there a way to make this work with multiple custom post types / content templates / views / pages?

I duplicated the custom code snippet and updated it with the new view, post, page, and template id's, but it doesn't work. I noticed that it stops working when I change the function name, and it conflicts with the original code when the function name is the same. Is there a way to make it work for more than just that page, views, and content template?

#2577455

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

The code snippet that Minesh shared, works by targeting specific views IDs. And based on those views IDs, it sets the relationship filter for the different relationships.

If you could share the temporary admin access details along with the example pages where you'd like the code snippet to work, I'll be able to suggest some adjustments to that code snippet, accordingly.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

#2578579

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for sharing these details.

I've studied your website's current setup and the requirements that you've shared and here are my findings.

To be able to show the repeating field group data from individual posts, on separate pages, the custom code approach that Minesh suggested earlier will become too complex to manage and extend.

A better alternate, in this case, would be to use the classic/legacy views in the single post content templates like 'Copywriting Single'.

For example, currently, I have disabled the custom code snippet from the Toolset's custom section. And in the content template 'Copywriting Single', for the 'Taglines' heading section, I've added a classic/legacy view named 'Taglines View - classic editor'.
hidden link

This view is set to show the 'Tagline' repeatable field group posts, with a relationship filter to 'Select items from the Tagline group that are a related to the current post in the loop.'
( screenshot: hidden link )

This view is set to show the content using a new content template 'Loop item in Taglines View - classic editor' so that you can still design the output of this view using the blocks editor:
hidden link

You can see that the output of this new classic view for the 'Taglines' heading section, is working on the single 'copywriting' post page, as well as the page 'Written Copy':
hidden link
hidden link

Similarly, you can replace the blocks-based views for the other repeatable field group sections with their respective classic/legacy views and they'll work when called on the separate pages and you won't need to add any extra custom code.

I hope this helps and please let me know if you need further assistance.

#2579249

That worked great. The original solution was great for the previous setup, but in the end, this new solution makes more sense for how many times I will need to be embedding views into different pages.

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