Skip Navigation

[Resolved] How to display repeating custom fields in a view

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

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

This topic contains 1 reply, has 1 voice.

Last updated by katrina 4 years, 10 months ago.

Author
Posts
#1440811
repeatingfieldsview.jpg

Tell us what you are trying to do? Display a list of Repeating Custom Field values on a Page

Is there any documentation that you are following?

1) https://toolset.com/documentation/getting-started-with-toolset/creating-and-displaying-repeatable-field-groups/
2) https://toolset.com/forums/topic/unable-to-show-repeating-custom-field-images-in-a-loop/

Is there a similar example that we can see?

What is the link to your site? I can provide in a private message.

I would like to show a list of Frequently Asked Questions (FAQs) in an accordion on a Page.

I don't want to create a Custom Post type for my questions and answers, because there are many of them and the questions and answers are fairly short. So instead, I created a Repeatable Custom Field which has two fields; Question and Answer. This was my client can easily edit and add/remove questions by editing just one area of the website (i.e. one page).

Since I will only have this list of FAQs on one single page of my site, the settings for this Repeatable Custom Field group are set to show the group on "Pages" and on my Content Template called "Our Process" which is only used for a single page on my site, also called "Our Process".

The part I am having trouble with is now how to display these FAQs on my page.

I created a View called "FAQs" and inserted that View into my "Our Process" Content Template. I then use that Content Template for my Our Process page only.

My "FAQs" View settings are shown in the attached screenshot, and the code in my loop is as follows:

[wpv-layout-start]
	[wpv-items-found] 
	<!-- wpv-loop-start --> 
		<wpv-loop>
        [wpv-for-each field="wpcf-question-answer"] 
			<h2 >[types field='question'][/types]</h2>
          	<div >
				[types field='answer'][/types]
			</div>
		[/wpv-for-each] 
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

But i get no results ๐Ÿ™

I am not so concerned with the accordion markupโ€”I'll configure that later. For now I just want to at least achieve a list of the Questions and Answers appearing on my page.

What am I doing wrong?
Is it because I added a repeating Custom Fields group to a Page and not a particular Post type?
Is my [wpv-for-each] code wrong?

Thank you in advance for any help!

#1440823

I figured it out. I no longer even needed the [wpv-for-each] code, because now that I can select the Repeatable Fields Group as the source in the settings at the top of my View, it's unnecessary ๐Ÿ™‚

Now I just have:

[wpv-layout-start]
	[wpv-items-found] 
	<!-- wpv-loop-start --> 
		<wpv-loop>
			<h2>[types field='question'][/types]</h2>
                        [types field='answer'][/types]
            </div>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]