Sort by featured

WordPress Business Themes Forums Responsive Themes Coupon Theme Sort by featured Reply To: Sort by featured

WordPress Business Themes Forums Responsive Themes Coupon Theme Sort by featured Reply To: Sort by featured

  • JamesD
    JamesD
    Super Guru 1,296 points

    Hello Alexey,

    Add this to your ‘_functions.php’ file and see if that helps ;-).

    /**
     * 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');
    March 1, 2019 at 9:19 am
  • Didn't find what you were after?

    Chat with us now

    or contact our support team