Gets the most viewed posts ordered by views count. This function is a wrapper for get_posts() and it accepts all the get_posts() parameters.
Usage
pvc_get_most_viewed_posts( $args = array() );
Parameters
$args
array
Array of optional arguments
Return
Array of most viewed posts stored in the array of post objects.
Example
Getting pages ordered by post views in ascending order.
$args = array( 'order' => 'asc', 'post_type' => 'page' ); $most_viewed = pvc_get_most_viewed_posts( $args );
Or same as above using get_posts() function.
$args = array( 'order' => 'asc', 'post_type' => 'event', // required by PVC 'suppress_filters' => false, 'orderby' => 'post_views', 'fields' => '' ); $most_viewed = get_posts( $args );