Skip Navigation

[Resolved] Show Repeatable field group items on page

This support ticket is created 4 years, 9 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
- 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 jefM 4 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#1484749
Schermafbeelding 2020-01-29 om 14.14.57.png
Schermafbeelding 2020-01-29 om 14.10.19.png
Schermafbeelding 2020-01-29 om 14.07.53.png

Hi,

I'm having an issue with getting the repeatable field group items which are child of a page.

When I do the query (screenshot of query uploaded) I get all the repeatable field groups that are also child of other pages, so not just the RFG's of that specific page. An echo of the $post->ID returns the specific ID. Just removing the 'toolset_relationships' query yields the same result, so it seems to ignore that completely.

I would like to do this as a wp_query, so no View. Website is made in combination with 'Timber'.

Thanks in advance!

#1486837

Hi,

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

I haven't used 'Timber' before, but using simple PHP code and "WP_Query", I was able to make the Toolset relationship query work:
( for parent post with ID 6 )


$args = array(
  'post_type' => 'block',
  'numberposts' => -1,
  'order' => 'ASC',
  'toolset_relationships' => array(
    'role' => 'child',
    'related_to' => 6,
    'relationship' => 'block'
  ),
);

$the_query = new WP_Query( $args );
while ( $the_query->have_posts() ){
  $the_query->the_post();
  the_title();
  echo '<br />';
}

Alternatively, you can also use the "toolset_get_related_posts" function, directly:
( ref: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts )


$child_ids = toolset_get_related_posts(
    6,
    'block',
    'parent',
    100,
    0,
    array(),
    'post_id',
    'child'
);
 
if ( $child_ids ){
    foreach ( $child_ids as $child_id ){
        echo get_the_title($child_id);
        echo '<br />';
    }
}

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

regards,
Waqar

#1487097
Schermafbeelding 2020-01-30 om 17.21.57.png

Hi,

Thanks for the reply. I don't get it to work with the query. There seems to be a problem with the RFG's in combination with Timber because if if use get_posts on a post of the RFG I get no results even though the ID clearly exists.. Using the query you provided yields all the posts of the RFG regardless of the page ID I query.

I got it to work with toolset_get_related_posts and then foreach loop over all the fields I need. That way I only get the childs of the specific page.

Thanks for the help!

#1487109

My issue is resolved now. Thank you!