Hi,
I want the archive (custom) to sort by most views.
The standard order is date. Post type is download.
But when I try:
function pre_get_posts_hook($wp_query) {
if ( is_archive() && $wp_query->is_main_query() ) {
$wp_query->set( ‘orderby’, ‘post_views’ );
$wp_query->set( ‘post_type’, ‘download’ );
$wp_query->set( ‘order’, ‘DESC’ );
return $wp_query;
}
}
It is not working. How can i change the default archive ‘order by’ to most views for custom post types?
Thanks!