Ordering posts in get_posts

Question

I am having a custom block which uses the following code to fetch a list of comma separated posts.

    $numberposts = "7,9,5,10";
    $post_ids = explode( ',', $numberposts );
    $args = array( 
        'post_type' => 'post',
        'post__in' => $post_ids,
        'numberposts' => '9999999'
    );
    $list_posts = get_posts( $args );

The problem is that the returned data is not ordered by the original order of the ids supplied. Is it possible to do that? Can you please help?

0
asanas 5 months 2020-12-23T06:10:53-05:00 0 Answers 8 views 0

Leave an answer

Browse
Browse