Skip Navigation

[Resolved] Creating a View

This support ticket is created 4 years, 7 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: Africa/Casablanca (GMT+01:00)

This topic contains 16 replies, has 2 voices.

Last updated by filipeC 4 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#1673241

The code seems correct to me. It should return true if the post has any children of the relationship ('shipwreck','gun-type') and false if no children are found.

If it does not work for you, change the relationship array with the repeatable group slug "gun-type", so code would be:

$guntypeids = toolset_get_related_posts( 
      get_the_id(),
      'gun-type',
      [
        'query_by_role' => 'parent',
        'role_to_return' => 'child',
        'need_found_rows' => true,
      ]
    );
$guntypecount = $guntypeids ['found_rows'];
if ($guntypecount > 0) {
return true;
}

If it does not work, I'll give it a try locally to make sure that we have a code that calculates correctly the count of children in a repeatable group. Then we'll check if it will work with your plugin.

#1673901

That works! Thanks so much.