Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • spitzerg

    (@spitzerg)

    Thanks for the link, unfortunately I saw that post earlier and its not exactly the same problem. That post is talking about limiting results based on the value of a meta field whereas all dgilfoy, masev and myself want to do is sort based on a meta field. They also mention sorting on the meta field but based on the patches above I think the issue is a problem in meta_query if a key is set with no value.

    spitzerg

    (@spitzerg)

    See https://core.trac.www.ads-software.com/ticket/16742.

    Unfortunately not a solution yet but working on one. For my situation I just applied the first diff (1 line added to wp-includes/query.php) and it seems to be fine for all of my cases thus far despite the potential duplicates mentioned in the discussion.

    I would think something as significant as this would receive more testing, it seems a pretty major bug.

    Anyway, hope that helps until something gets rolled into 3.1.1 or 3.2.

    Another option is to add a request filter:

    add_filter( 'request', 'my_request_filter' );
    function my_request_filter( $query_vars ) {
        if( isset( $_GET['s'] ) && empty( $_GET['s'] ) ) {
            $query_vars['s'] = " ";
        }
        return $query_vars;
    }

    Then if you’re reusing the search query in your search form don’t forget to trim it so you don’t end up with one or more spaces (just to keep things clean, probably won’t affect results.

    <input type="text" name="s" id="s" value="<?php echo trim( get_search_query() ); ?>" />

    Hope this helps, it seems to be working thus far on my site and doesn’t involve changing any of the WP code making upgrades easier.

Viewing 3 replies - 1 through 3 (of 3 total)