How to sort wordpress posts already selected by WP_QUERY

Question

English is not my first language, sorry 🙂

I need differend per paginate page sorting.

For exemple, I created the loop:

 $qargs = array(
                    'posts_per_page' => 15,
                    'no_found_rows'  => true,
                    'order' => 'DESC',
                    'post_type' => 'post',
                    'suppress_filters' => false,
                    'orderby' => 'post_views', // here I order my posts by views
                    'fields' => '',
                    'date_query' => array(
                        array(
                            'after'     => '-7 days',
                            'column' => 'post_date',
                        ),
                    ),
posts_query = new WP_Query( $qargs );

And now I can display 15 selected posts sorted by views like this:

if ( $posts_query->have_posts() ): ?>
                while ( $posts_query->have_posts() ):
                    $posts_query->the_post();
.......

But I need to select 15 most viewed posts and after that to sort them by date.

Is it possible?

Thank you!

0
Andrew 2 months 0 Answers 6 views 0

Leave an answer