Post_views not working in amp plugin and add oderby rand
PLz add
/**
* Get most viewed posts.
*
* @param array $args
* @return array
*/
if ( ! function_exists( ‘pvc_get_most_viewed_posts’ ) ) {
function pvc_get_most_viewed_posts( $args = [] ) {
$args = array_merge(
[
‘posts_per_page’ => 10,
‘order’ => ‘desc’,
‘post_type’ => ‘post’,
‘fields’ => ”
],
$args
);
$args = apply_filters( ‘pvc_get_most_viewed_posts_args’, $args );
// force to use filters
$args[‘suppress_filters’] = false;
// force to use post views as order
$args[‘orderby’] = ‘post_views’;
return apply_filters( ‘pvc_get_most_viewed_posts’, get_posts( $args ), $args );
}
}