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

  • Chris
    Chris
    Newbie 34 points

    @JamesD
    Thank you for the reply :)

    When I tried

    /**
    * 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', 'DESC');
    }
    add_filter( 'pre_get_posts', '_custom_order');

    It did seem to mostly work, pushing my expired listings to bottom of sort. Except on a couple of tag pages. I’d have to change the way I use expiration dates currently.
    But the problem is it weirdly removed all front page listings and my main navigation menu.
    ᗧ···ᗣ···ᗣ··
    Any way to just target expired listings like is done to add “expired” class?

    <?php if($vv['expired'] == 1){ echo "expired"; } ?>

    I then tried the number of listings snippet, but isolated like:

    function _custom_order($wp_obj){
    $wp_obj->set('posts_per_page', 20);
    }
    add_filter( 'pre_get_posts', '_custom_order');

    And this worked fantastic, but I use the “Used Today” elementor widgets some sidebars. And this increased those posts from 5 to 20 also which tanked the page. Do you know how to isolate the per page to only main content listings?

    Thanks again!

    Thanks again!

    April 2, 2019 at 7:50 am
  • Didn't find what you were after?

    Chat with us now

    or contact our support team