reply

Home Forums Responsive Themes Coupon Theme Sort by featured Reply To: Sort by featured

  • JamesD
    JamesD
    Super Guru 1,719 points
    March 31, 2019 at 12:22 am

    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');

  • New Business Themes for WordPress 2020

    Start your new website today!

    View Business Themes