Sauter la navigation

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

This support ticket is created Il y a 2 années. 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.

Ce sujet contient 1 réponse, a 1 voix.

Dernière mise à jour par romanB-3 Il y a 2 années.

Auteur
Publications
#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!