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,289 points

    Hello Chris,

    Does this do what you’re looking for?
    /**
    * Change coupon order by expiry date.
    *
    * ASC = Order with the ones to expire first (soon to expire)
    * DESC = Order with the last to be expired first
    *
    * @param WP_Query Object $wp_obj
    * @return WP_Query Object $wp_obj
    */
    function _custom_order($wp_obj){
    $wp_obj->set('meta_key', 'expiry_date');
    $wp_obj->set('orderby', 'meta_value');
    $wp_obj->set('order', 'ASC');
    }
    add_filter( 'pre_get_posts', '_custom_order');

    March 31, 2019 at 12:22 am
  • Didn't find what you were after?

    Chat with us now

    or contact our support team