Support

Account

Forum Replies Created

  • I resolved it !

    I don’t know why but with my custom post type, in core/fields/post_object.php, it runs get_pages() function instead of get_posts() (maybe).

    So I change the $args['numberposts'] by $args['number'] et voila !

    Romain

  • Hi @elliot,

    This is strange, $args are ok if I print it on core/fields/post_object.php at line 171.

    Array ( [numberposts] => 7 [post_type] => emission [orderby] => date [order] => date [post_status] => publish [suppress_filters] => [sort_column] => date [sort_order] => DESC )

  • Hi elliot,

    Here the $args

    Array
    (
        [numberposts] => 7
        [post_type] => emission
        [orderby] => date
        [order] => date
        [post_status] => publish
        [suppress_filters] => 
        [sort_column] => date
        [sort_order] => DESC
    )
  • Here it is !

    I try numberposts whithout success, I don’t know if it’s important but for your information the select field list custom posts type.

    add_filter('acf/fields/post_object/query/key=*my_field_key*', 'change_posts_order', 10, 3);
    
    function change_posts_order( $args, $field, $post )
    {
    
        $args['numberposts'] = 7;
        $args['sort_order'] = 'DESC';
        $args['sort_column']  = 'date';
        $args['orderby'] = 'date';
        $args['order'] = 'date';
        $args['post_status'] = 'publish';
    
        return $args;
    }

    Thanks

Viewing 4 posts - 1 through 4 (of 4 total)