• Resolved tul60522

    (@tul60522)


    We have an existing plugin that is using this on a search page:

    
    global $query_string;
    $query_args = explode("&", $query_string);
    $search_query = array();
    if( strlen($query_string) > 0 ) {
        foreach($query_args as $key => $string) {
            $query_split = explode("=", $string);
            $search_query[$query_split[0]] = urldecode($query_split[1]);
        }
    }
    
    $search = new WP_Query($search_query);
    
    ...if($search->have_posts())...
    
    

    The if $search->have_posts fires correctly when the Relevanssi plugin is OFF. When ON, search breaks. And if we replace the WP_Query with the following:

    
    $search = new WP_Query();
    $search->parse_query($search_query);
    relevanssi_do_query($search_query);
    

    …the $search->have_posts() ends up empty. I’ve tried a few more options from various support threads to no avail.

    • This topic was modified 5 years, 8 months ago by tul60522.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    It should be

    $search = new WP_Query();
    $search->parse_query($search_query);
    relevanssi_do_query($search);

    You have the wrong variable name there, that’s why it’s coming up empty.

    Thread Starter tul60522

    (@tul60522)

    @msaari thank you. I could have sworn I tried this, but my eyes must have been just too tired yesterday. I really appreciate you getting back to me so quickly.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘new WP_Query’ is closed to new replies.