Forums Forums Search & Filter Pro ordering by meta key is not working

Tagged: 

Viewing 3 posts - 11 through 13 (of 13 total)
  • Anonymous
    #146920

    Yeah it should be ok, it’s just ordinary UNIX timestamp which I get from time PHP function.. there shoudnt be any problem, or am I missing something??

    Anonymous
    #146930

    You have an error in your plugin. I did some debugging and I figured out that WP_Query’s orderby and meta_key values are not properly set. This code fixed my problem.

    function czus_fix_wrong_filter_orderby( $query ) {
    if(!is_admin() && is_main_query() && $query->query[‘search_filter_id’] === 95) {
    $query->set( ‘meta_key’, ‘last_update’ );
    $query->set( ‘orderby’, ‘meta_value_num’ );
    }
    }
    add_action( ‘pre_get_posts’, ‘czus_fix_wrong_filter_orderby’ );

    Trevor
    #146973
    This reply has been marked as private.
Viewing 3 posts - 11 through 13 (of 13 total)