Passing WP_Query to another plugin

Forums › Forums › Search & Filter Pro › Passing WP_Query to another plugin

Viewing 10 posts – 1 through 10 (of 18 total)
  • Anonymous
    #195268

    Related to another support question I posted, I’m passing a WP_Query object from Search and Filter Pro to another plugin (Geomashup) in order to display search results on a map.

    It works on initial page load, but when attempting to update the results via AJAX, the following appears:

    … and so on, ad infinitum, evidently some kind of loop where an HTML container gets repeatedly written inside of itself. Inspecting the HTML, it appears that some characters (double quotes, backslashes) are being doubled and/or escaped like so:

    <iframe name=”\"gm-map-1\"” src=”\"https:\/\/website.com\/?geo_mashup_content=render-map&map_data_key=6669c66d9609d8f9a1821e6928f3c584&map_content=global&show_future=1&name=gm-map-1&object_ids=174371529565047,174371529565046,174371529663274,174371529663195,174371529609792,174371529596380,174371529596379,174371529609791,174371529596378,174371529538729,174371529610349,174371529538728,174371529610348,174371529538726,174371529538724,174371529610352,174371529561088,174371529561087,174371529561086,174371529633478&sfid=174371529654519&sf_action=get_data&sf_data=results&_sf_s=some_keyword&post_date=12022018\\\\\\\\\\\\\\\\"\\\\"\"” style=”\"position:” absolute;=”” top:=”” 0;=”” left:=”” width:=”” 100%;=”” height:=”” border:=”” none;=”” overflow:=”” hidden;\”=””><\/iframe><\/div><\/div>”}</iframe>

    I’ve tried things like json_decode() and stripslashes() on the results before displaying, but it is clear there is an error that I cannot identify, and I cannot tell if Search and Filter is involved. Would you be able to suggest troubleshooting advice?

    Anonymous
    #195272
    This reply has been marked as private.
    Anonymous
    #195274
    This reply has been marked as private.
    Anonymous
    #195276
    This reply has been marked as private.
    Trevor
    #195299

    It looks like the data is being passed INSIDE the while loop. The basic archive structure is this:

    if ( $query->have_posts() )
    {
    	
    // Pass the query here	
    
        while ($query->have_posts())
    	{
    		$query->the_post();
    		
    // Looks like the query is being passed here
    
        }
    
    }
    Anonymous
    #195315

    That eliminates the looping but the query results are empty. There may be something I’m missing in the documentation. I’m doing this:

    if ( $query->have_posts() )
    {
       echo GeoMashup::map([
       'map_content' => $query,
       'show_future' => True,
       ]);
       while ($query->have_posts())
    	{
             // and so on

    Does that look correct?

    Anonymous
    #195321
    This reply has been marked as private.
    Trevor
    #195392

    Where you use $query are you sure that is the name of the query array? What does the map_content variable need by way of data? $query will give it the whole array. It might be useful to use print_r inside `

    
    

    HTML tags on that $query variable to see if it is empty or not.

    Anonymous
    #195400

    Per the other plugin’s docs, the map_content variable takes a WP Query object.

    When I print_r($query), it shows WP_Query Object ( [query] => Array ( [paged] => 1 [search_filter_id] => 174371529654519 [search_filter_override] => [posts_per_page] => 10 [post_status] => Array ( [0] => publish ) [ignore_sticky_posts] => 1 [meta_query] => Array ( ) [post_type] => simcal-concerts [orderby] => Array ( [date] => ASC ) [date_query] => Array ( [after] => Array ( [day] => 05 [month] => 12 [year] => 2018 ) [before] => Array ( [day] => 01 [month] => 06 [year] => 2019 ) [inclusive] => 1 ) [post__in] => Array ( [0] => 174371529431586 [1] => 174371529431587 [2] => 174371529431588 [3] => 174371529431589 [4] => 174371529431590 [5] => 174371529431591 [6] => 174371529431592 [7] => 174371529431593 [8] => 174371529431595 [9] => 174371529431596 [10] => (…) and so on, through a fairly large number of results.

    When reloaded via AJAX, it shows something that looks more like a JSON response, with HTML characters escaped.

    Trevor
    #195405
    This reply has been marked as private.
Viewing 10 posts – 1 through 10 (of 18 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.