Skip Navigation

[Resolved] I need help creating a views for repeatable fieds

This support ticket is created 5 years 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 4 replies, has 2 voices.

Last updated by raquelD 5 years ago.

Assisted by: Nigel.

Author
Posts
#1457763

Hello,

I am using Gym Template on my website and I want to create this view: hidden link ( the Opening Hours ), in my new post type. Please let me know how can I create the same view but for different post type and it's hour's fields which are created the same way.

#1458069

Nigel
Supporter

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

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

Hi Raquel

Any View begins with the Content Selection: which post type is being queried.

So if you already have a working example from a different post type on your site, the easiest thing would likely be to edit the View and change the Content Selection to match the post type you want to actually use.

Are the opening hours created using the same existing custom fields? If that's the case then that might be all you need to do.

If you created a new field group for opening hour fields that have different names/slugs than the existing fields then you would need to recreate the output of the View, too, replacing the existing fields with the new fields.

If you need help with that, are you using the classic Views editor or the new Blocks editor?

#1458189

Hello Nigel,

Thank you for your reply. Answering your question, I'm using the new Blocks editor. I tried to replace the names and I also created new custom fields but these weren't showing up in the page. Basically, replacing hasn't worked for me.

In the meantime, I've been working with a developer on this. But I'd like to understand how it's done.

Thank you again and happy new year.

Raquel

#1459557

Nigel
Supporter

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

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

Hi Raquel

I installed a copy of the Gym site locally and see that you won't be able to re-use the existing fields, you need to create a new group for your new post type.

You will have created a new post type (I don't know your project, let's say it is "Dentists"), and you want to use the same opening hours custom fields with your dentist post type.

Ordinarily you could edit the existing custom field group for Gyms and make the same fields available to your dentist post type (and no longer available to gyms, if you will be deleting that post type), so the field names and slugs etc. would be just the same as before.

But, those opening hour fields are implemented using repeatable field groups (screenshot), and it is a limitation arising from how they are implemented that they are tied to a specific post type, so you cannot re-use the existing fields for another post type, you will have to recreate them.

So make a new custom field group for dentists, adding the fields you need, including reproducing how the opening hour fields are set up in the field group for gyms. You will run into the problem that the slugs for the fields (such as "day-of-the-week") are already used, and you will need to use different ones.

You should then be able to publish your dentist posts with values for the custom fields, including opening hours.

Now, to the main point of your question.

You will have made a template for dentists, and want to display the opening hours.

So you will need to insert a View block, and you will be creating a new View.

After choosing the output style, you will choose the content selection, and you should find your new repeatable field group for opening hours available to choose.

You would then design the output of the View to include the required fields. If you examine the existing View in the Gym template you'll see that in the output section it uses a container block with a column block inside with 2 columns, with the first showing the day and the second showing the hours, each coming from the repeatable field group.

You may find the Getting Started guide for using Views to display lists of content helpful, although it doesn't refer specifically to displaying repeatable field groups: https://toolset.com/documentation/getting-started-with-toolset/create-and-display-custom-lists-of-content/

#1460409

My issue is resolved now. Thank you!