Order by: post_views is it possible?

Hi

I have installed the PVC (Post Views Counter) Plugin.

After installation I can build a Custom Looper Provider Type 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 );

It would be possible to use the “post_views” parameter directly inside Cornerstone into a:

  • Query Builder
  • Query String

to “Order By” the results?

What do you think is the best and lightest solution:

  • an external Custom Looper Provider Type?
  • an internal Query Builder or Query String with “Order by: post_views” (if possible)?

Please could you also help me in order to undestand the meaning and “How To” of:
image

Thank You

Daniele

Hi Daniele,

Thanks for reaching out.
You can use the array of arguments for the Query and then just use the http_build_query function to format it into the Query String.

$args = array(
    'order'	=> 'asc',
    'post_type' => 'event',
    // required by PVC
    'suppress_filters' => false,
    'orderby' => 'post_views',
    'fields' => ''
);

echo http_build_query($arr);

I would suggest you go through the following thread which may help you on this.



Thanks