Forums › Forums › Search & Filter Pro › Passing WP_Query to another plugin
- This topic has 17 replies, 3 voices, and was last updated 7 years, 11 months ago by
Ross.
-
Anonymous(Private) December 4, 2018 at 6:50 pm #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?
Trevor(Private) December 5, 2018 at 10:41 am #195299It 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(Private) December 5, 2018 at 11:40 am #195315That 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 onDoes that look correct?
Trevor(Private) December 5, 2018 at 4:06 pm #195392Where you use
$queryare 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(Private) December 5, 2018 at 4:36 pm #195400Per 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.
-
AuthorPosts