Ordering posts in get_posts


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?

asanas 4 weeks 0 Answers 8 views 0

Leave an answer