Skip Navigation

[Resolved] Custom fields: How to retrieve specific value from repeatable group

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 12 replies, has 2 voices.

Last updated by Minesh 1 year, 1 month ago.

Assisted by: Minesh.

Author
Posts
#2649839

Hi,

in the website I am building (example page: hidden link
I have products with related accessories. Both are created with 2 different custom post types.

Previously, I had created different custom fields within the product page, where the user can fill the details for each accessory. Displaying those fields in each accessory custom page was easy:

[types field='accesorio-2-imagen' title='%%TITLE%%' alt='%%ALT%%' size='full'][/types]
<div class="accesorio_titulo"><h3>[types field='accesorio-2-titulo'][/types]</h3></div>
<div class="accesorio_ref">Referencia: [types field='accesorio-2-referencia'][/types]</div>
<div class="accesorio_desc">[types field='accesorio-2-descripcion'][/types]</div>

I now have to change this and must use a repeatable group instead, but I don't understand how to show only specific fields: accessory post 1 would display title+description+image from the first fields. The second post would display the second fields, and so on.

How can I use a repeatable group to achieve what I was doing before with regular fields?

Thank you in advance

Regards,

Luca

#2650003

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Here is the official Doc that shows information about how you can create and display the repeating field group:
- https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/

Can you please try to follow that and let me know if you require further assistance.

#2650007

Hi, thank you for your reply.

I had already read the official documentation, but I cannot see any reference to what I am trying to do:

- displaying inside a custom post type a repeatable field that relates to another custom post type
- displaying only one specific value inside each post and not everyone of them.

#2650009

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please share one example on what post you want to display what repeating field group item with its associated custom field and share admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2650061

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

In post 1, I'd like to display the first repeable fields that had been added inside this other custom posts: hidden link
==>
With the link you shared - I see there are 12 posts available::
- hidden link

What posts repeatable group items you want to add to the post "1" on the following link:
=> hidden link

Do you mean that you want to add 1st item I can see when I edit every posts of post type "autoclaves" and add that 1st item of repeating field group to the post "1"?

#2650087

Hi Minesh,

I would like it to work like it did when I was simply using regular custom fields.
Previously I had

[types field='accesorio-1-imagen' title='%%TITLE%%' alt='%%ALT%%' size='full'][/types]
<div class="accesorio_titulo"><h3>[types field='accesorio-1-titulo'][/types]</h3></div>
<div class="accesorio_ref">Referencia: [types field='accesorio-1-referencia'][/types]</div>
<div class="accesorio_desc">[types field='accesorio-1-descripcion'][/types]</div>

So that depending on which one of the 12 "autoclave" the user were, the corresponding fields would show up.

And like you said, I would add to post "1" the first item of repeating field group to the post "1".
Then I would add to post "2" the second items and so on...

Thank you for your time and your support

#2650091

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

And like you said, I would add to post "1" the first item of repeating field group to the post "1".
Then I would add to post "2" the second items and so on...
==>
What you said above is still confusing.

Do you mean that there will be post with title "1" in post type "accesorio" which we have already and then you will have also another post with post title "1" in post type "autoclaves" and you want that the first item of repeating field group of post with title "1" of post type "autoclaves" should be added to the post "1" of post type "accesorio".

Can you please setup a example post with repeating field group items and tell me what item you want to display where? Also few screenshot would be helpful.

#2650093

Sorry about the confusion. I do find it difficult to explain.

There won't be any new posts, neither in "accessories" or in "autoclave" types.

I don't want to create another post called "1". What I need to do is to change the current content of all the "accessories" posts and replace it with repeatable fields in order to achieve the same result I am getting with regular custom fields.

I have tried to show you what I mean here: hidden link

#2650095

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Repeating field group managed as one-to-many post relationship internally.

So - what if you create one-to-many post relationship between your post types to connect both posts.
- https://toolset.com/course-lesson/what-are-post-relationships-and-how-they-work/

I still do not get what exactly you want maybe I get something but its not the exact what you want to achieve.

I understand you want to display something of post type x to post type b but still the information you shared is not that accurate.

Please be clear what you want to achieve. Do you want to add repeating field group to post type "accesorio"?

I already seen repeating field group added to post type "autoclaves" - do you want to keep that?

#2650113

Hi,

yes I want to display the repeating fields from post type "autoclave" inside posts "accesories"
And yes, I want to keep the field group added to post type autoclaves.

I am not sure whether the post relationship should be one-to-many or many-to-many, since each accessory post is related to multiple autoclave posts, and viceversa...

Autoclave 1 can have accessories 1,2,3,4,5 and accessory 1 can be associated with autoclave 1,2,3,4,5...

If you look at the current content of the accessory posts, you should see what I am trying to achieve, since it's exactly the same thing.

A further brief explanation on this video: hidden link

#2650377

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The thing is that it seems you are misunderstood something here that is eventually not suppose to work as you think.

I know now what you want. I see you have number of "Accesorio" fields added to "autoclaves" post.
- hidden link

You want to copy the existing "Accesorio" fields to another post type "accesorio" post. There is no such feature available.

You will have custom field values saved with different custom fields like Accesorio 1, Accesorio 2, Accesorio 3 upto Accesorio 32.

Now you want that those post meta should be converted as repeating field group under the post type "accesorio". So for example, you have post "01" with post type "accesorio" and you want to copy the custom field values stored with "autoclaves" post custom field Accesorio 1.

There is no such feature available and again its does not make sense as repeating field group managed as one-to-many post relationship internally and also there is no connection to identify from what "autoclaves" post we have to get the custom fields value of custom field Accesorio 1 to store with post "01" of post type "accesorio".

I see you still not firm what post relationship you want to go with. The structure of your site is critical thing and you should not be able to change that again and again. If you do not know with what structure you need, I suggest you should get help from any expert who offer the base structural design for your site.

If you want to learn on your own, we offer number of courses:
- https://toolset.com/course/

In addition to that we also offer free test platform http://www.discover-wp.com where we offer number of sites build on top using the Toolset feature (basic to advance). You are welcome to create test site using any of the reference site we offer:
- https://discover-wp.com/site-templates/

I suggests you learn first how Toolset works and what are the possibilities using it and then you should create your site structure.

#2650383

Mmh, I see I am still unclear.

I do NOT want to use the custom fields like Accesorio 1, Accesorio 2, Accesorio 3 up to Accesorio 32, and I do NOT want to convert them. I want to DELETE them and REPLACE them entirely with the Repeteable group.

The cliente doesn't want to have 32 custom fields and have to fill them in, since not all the products have 32 accesories.
He wants to add himself the accessory details one by one. Using the repeatable fields group seems exactly what he wants.

What I was trying to achieve then was a way to dynamically load the repeatable group information inside the accessory post, the same way I was doing it before with the 32 custom fields. In that case, the connection is working flawlessly.

You say then it's impossible to replicate the same way of working with a repeatable group?

#2650385

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I do NOT want to use the custom fields like Accesorio 1, Accesorio 2, Accesorio 3 up to Accesorio 32, and I do NOT want to convert them. I want to DELETE them and REPLACE them entirely with the Repeteable group.
==>
Ok - if you want to replace that, then I see you already have repeating field group available "Accesorios repeatable group" what is the use of that.

You can go ahead and add a repeating field group to your desired post type and add those fields to your repeating field group:
- Accesorio - imagen
- Accesorio : título
- Accesorio : referencia
- Accesorio : descripción

Please note that once you add your repeating field group, you will have to setup values for all those entries.

Then you can also have one-to-many post relationship between post type "autoclaves" (one) and "accesorio" (many).

Then you can setup all your posts with post type "accesorio" where you can setup repeating field group. But in that can as you can see repeating field group is attached to post type "accesorio" and "accesorio" is connected to "autoclaves" using one to many post relationship.

If you need one to many post relationship - then I dont think you need repeating field group as one-to-many post relationship between post type "autoclaves" (one) and "accesorio" (many) is enough where you can add the following fields to custom field group and set this custom field group to display with post type "accesorio".
- Accesorio - imagen
- Accesorio : título
- Accesorio : referencia
- Accesorio : descripción

That way you can setup post with post type "accesorio" which will have information about above fields and connect those posts using one-to-many post relationship. Does that makes sense?

All in all, please note that having this structure change you will have to enter all the content as no content is going to copy from existing content.