Skip Navigation

[Resolved] Repeatable Group Order in a Custom Code implementation

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

Last updated by hendrikH 3 years, 12 months ago.

Assisted by: Minesh.

Author
Posts
#1602853

Hello Toolset Support,

Currently, I am using Toolset Repeatable Group with a "number" field to retrieve information via an API.

I have used the following code to retrieve the values of the fields into an array.


<?php
	$section_ids = toolset_get_related_posts(
	    get_the_ID(),
	    'pznsgroup',
	    'parent',
	    100,
	    0,
	    array(),
	    'post_id',
	    'child'
	);

	$new_pzn = array();

    if ( $section_ids ){
    foreach ( $section_ids as $section_id ){
        $section = get_post_meta( $section_id, '', false );
        $section_content = $section["wpcf-pznnumber-ratgeber"][0];

        array_push($new_pzn, $section_content);

    	}
     }

	if ( $new_pzn ){


		foreach ( $new_pzn as $single_new_pzn ){

			[... API stuff..]

?>

Upon getting the API results I have noticed that when I try to change the order of the Repeatable Fields, the end result/display is the same.
I there any way you can guide me on how to make the order functionality work?
Unfortunately, the site in question is a staging site and the access to it is limited.

Here are some screenshots:
hidden link
hidden link

Thank you!
Eduard P.

#1603563

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Do you mean that you want to display the items of the repeating field on the frontend based on the order which you set it from backend? If this is correct:
==>
The Repeating field group stores the order of repeating field items with the meta key: toolset-post-sortorder

So, you need to adjust the code as given under:

 $section_ids = toolset_get_related_posts(
        get_the_ID(),
        'pznsgroup',
        'parent',
        100,
        0,
        array('meta_key'=>'toolset-post-sortorder'),
        'post_id',
        'child',
         'meta_value_num',
         
    );

Please check the following related ticket:
https://toolset.com/forums/topic/query-repeating-field-group-values-in-order/#post-923583

#1603899

My issue is resolved now. Thank you!

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