Skip Navigation

[Resolved] #286 function to get only children from parent (1 to many relationship)

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 1 reply, has 1 voice.

Last updated by romanB-3 1 year, 11 months ago.

Author
Posts
#2542695

Hi,
This function is supposed to return only child "job" posts of the current "structure" parent post.

function filter_grid_by_current_structure( $query_args, $grid_id ) {
    if ( is_singular( 'structure' ) ) {
        $current_structure = get_the_ID();
        if ( (int) $grid_id == 17 ) {
            $related_jobs = toolset_get_related_posts( $current_structure, 'offre-de-la-structure', 'child');
            if ( !empty( $related_jobs ) ) {
                $query_args['post__in'] = $related_jobs;
            } else {
                $query_args['post__in'] = array(0);
            }
        }
    }
    return $query_args;
}

But it doesn't seem to work...

Any lead?

Thanks.

#2542721

My issue is resolved now. Thank you!