Skip Navigation

[Resolved] Creating a View

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.

This topic contains 16 replies, has 2 voices.

Last updated by filipeC 1 month, 2 weeks ago.

Assigned support staff: Jamal.

Author
Posts
#1673241

Jamal
Supporter

Languages: English (English ) French (Fran├žais )

Timezone: Africa/Casablanca (GMT+01:00)

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.