an
groups-icon

Sort by featured

Wait a minute... This content is very very old. We no longer sell or support this theme version. New Topics
  • Version 9
    0 points
    Beginner

    Hi

    I would like to set Featured as default sort and found this

    Sort by featured

    /**
    * Set to show ‘Featured’ first.
    *
    * @param WP_Query Object $wp_obj
    * @return WP_Query Object $wp_obj
    */
    function _custom_sort($wp_obj){
    $wp_obj->set(‘meta_key’, ‘featured’);
    $wp_obj->set(‘orderby’, ‘DESC’);
    return $wp_obj;
    }
    add_filter( ‘pre_get_posts’, ‘_custom_sort’);

    But if I use this code, only the featured entries are shown

    February 29, 2020 at 3:53 pm
  • Adnan
    28 points
    Beginner
    Members Only Content

    This reply is for PremiumPress customers only.

    Login Now
    February 29, 2020 at 3:56 pm

292

Views

1

Replies