Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter rtibbs44

    (@rtibbs44)

    Tried this on a recommendation over at the studiopress forum but it doesn’t work… or I should say it doesn’t work for the featured listings on the home page.

    //add random sort order to the Listings query
    add_action( ‘pre_get_posts’, ‘gsc_listing_random_sort_order’ );

    function gsc_listing_random_sort_order( $query ) {

    if( $query->is_main_query() && !is_admin() && is_post_type_archive( ‘listing’ ) ) {

    $query->set( ‘orderby’, ‘rand’ );
    $query->set( ‘posts_per_page’, ‘6’ );
    }

    Any ideas??

    Thread Starter rtibbs44

    (@rtibbs44)

    FYI,

    This works or seems to work. Use at your own risk.

    //add random sort order to the Listings query
    add_action( ‘pre_get_posts’, ‘gsc_listing_random_sort_order’ );

    function gsc_listing_random_sort_order( $query ) {

    if( $query->is_post_type_archive( ‘listing’ ) && !is_admin() ) {

    $query->set( ‘orderby’, ‘rand’ );
    }

    }

    Plugin Support Nick C

    (@modernnerd)

    Thanks for sharing that, rtibbs44 – it will be helpful to others!

    Thread Starter rtibbs44

    (@rtibbs44)

    Your welcome.

    Ginger Coolidge figured it out over at the Studiopress forum.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show listings in random order’ is closed to new replies.