Support

Account

Home Forums General Issues relationship filter – query by template and group by parent

Unread

relationship filter – query by template and group by parent

  • Hi, I’m using this code to to get only pages with certain template and it’s working fine, but results are all messed up since pages using the template have Parent and Child and I’m trying to order and group by parents, any idea how to achieve this?

    function my_relationship_query( $args, $field, $post_id ) {
    	
        // only show children of the current post being edited
        //$args['post_parent'] = 5915;
        
        
        // show only pages with this special template    
        $args['meta_key'] = '_wp_page_template';
        $args['meta_value'] = 'template-page-info.php';
    	
        // return
        return $args;
        
    }
    
    // filter for every field
    add_filter('acf/fields/relationship/query', 'my_relationship_query', 10, 3);
Viewing 1 post (of 1 total)

The topic ‘relationship filter – query by template and group by parent’ is closed to new replies.