Tagged: ,

  • This topic contains 1 voice and has 0 replies.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #32343

    peter023
    Participant

    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!

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.