June 17, 2013 at 8:21 pm #12834
[mashup width=”100%” height=”400″ hideEmpty=”true” query=”category_name=lachlan-catchment,rivers-creeks&post_type=events&meta_key=event_end_date&meta_value=20130618&meta_compare=<“]
returns nothing. Yet
[mashup width=”100%” height=”400″ hideEmpty=”true” query=”category_name=lachlan-catchment,rivers-creeks”]
correctly returns POIs for normal posts belonging to categories “lachlan-catchment” and “rivers-creeks”, and
[mashup width=”100%” height=”400″ hideEmpty=”true” query=”post_type=events&meta_key=event_end_date&meta_value=20130618&meta_compare=<“]
correctly returns POIs for “events” type posts with event_end_date < 20130618.
How would you combine the two queries to get all the POIs? Currently the long shortcode returns nothing.
AmirJune 18, 2013 at 12:57 pm #12845
Can anyone shed some light on this issue?
AmirJune 19, 2013 at 7:20 am #12856
I’m not sure if this is a problem with the query or a bug. To narrow it down, could you try the following:
1. Deactivate all of your other plugins and switch to the 2012 theme for a moment. Does the full query work? If so, a plugin or the theme is interfering with the WordPress query.
2. Add the code below to your theme file to check the query results without using MapPress. If they are still incorrect, there is a WordPress bug or something is wrong with the query itself:
<?php $wpq = new WP_Query('category_name=lachlan-catchment,rivers-creeks&post_type=events&meta_key=event_end_date&meta_value=20130618&meta_compare=<'); print_r($wpq); ?>
If the results for #2 are correct, then it’s a bug in MapPress and I’ll be happy to trace it for you – please send me an email with the contact form and provide an administrator login to the blog.June 19, 2013 at 10:10 am #12858
I tested your query in my system and I found the problem – WordPress is replacing the “<" with "<" when it appears in the shortcode. Since < is invalid, it then uses "=" for the comparison. I'll provide a workaround in MapPress for this issue in the next version. If you'd like an immediate fix, send me an email and I'll send you an updated version of the file that needs to be changed.June 19, 2013 at 1:51 pm #12863
Thanks Chris. Yes I would be grateful for an immediate fix.
Please email me at
By the way,
$wpq = new WP_Query(‘category_name=lachlan-catchment,rivers-creeks&post_type=events&meta_key=end_date&meta_value=20130618&meta_compare=<‘);
returns only the following
WP_Query Object ( [query_vars] => Array ( [category_name] => lachlan-catchment [post_type] => events [meta_key] => end_date [meta_value] => 20130618 [meta_compare] => < [error] => [m] => 0 [p] => 0 [post_parent] => [subpost] => [subpost_id] => [attachment] => [attachment_id] => 0 [name] => [static] => [pagename] => [page_id] => 0 [second] => [minute] => [hour] => [day] => 0 [monthnum] => 0 [year] => 0 [w] => 0 [tag] => [cat] => 29 [tag_id] => [author_name] => [feed] => [tb] => [paged] => 0 [comments_popup] => [preview] => [s] => [sentence] => [fields] => [menu_order] => [category__in] => Array ( ) [category__not_in] => Array ( ) [category__and] => Array ( ) [post__in] => Array ( ) [post__not_in] => Array ( ) [tag__in] => Array ( ) [tag__not_in] => Array ( ) [tag__and] => Array ( ) [tag_slug__in] => Array ( ) [tag_slug__and] => Array ( ) [ignore_sticky_posts] => [suppress_filters] => [cache_results] => 1 [update_post_term_cache] => 1 [update_post_meta_cache] => 1 [posts_per_page] => 10 [nopaging] => [comments_per_page] => 50 [no_found_rows] => [order] => DESC ) [tax_query] => WP_Tax_Query Object ( [queries] => Array (  => Array ( [taxonomy] => category [terms] => Array (  => lachlan-catchment  => rivers-creeks ) [include_children] => 1 [field] => slug [operator] => IN ) ) [relation] => AND ) [meta_query] => WP_Meta_Query Object ( [queries] => Array (  => Array ( [key] => end_date [compare] => < [value] => 20130618 ) ) [relation] => AND ) [post_count] => 0 [current_post] => -1 [in_the_loop] => [comment_count] => 0 [current_comment] => -1 [found_posts] => 0 [max_num_pages] => 0 [max_num_comment_pages] => 0 [is_single] => [is_preview] => [is_page] => [is_archive] => 1 [is_date] => [is_year] => [is_month] => [is_day] => [is_time] => [is_author] => [is_category] => 1 [is_tag] => [is_tax] => [is_search] => [is_feed] => [is_comment_feed] => [is_trackback] => [is_home] => [is_404] => [is_comments_popup] => [is_paged] => [is_admin] => [is_attachment] => [is_singular] => [is_robots] => [is_posts_page] => [is_post_type_archive] => 1 [query_vars_hash] => 9e115d762c47fb4609a0b0cf54391e51 [query_vars_changed] => [thumbnails_cached] => [query] => Array ( [category_name] => lachlan-catchment,rivers-creeks [post_type] => events [meta_key] => end_date [meta_value] => 20130618 [meta_compare] => < ) [request] => SELECT SQL_CALC_FOUND_ROWS lrwg_posts.ID FROM lrwg_posts INNER JOIN lrwg_term_relationships ON (lrwg_posts.ID = lrwg_term_relationships.object_id) INNER JOIN lrwg_postmeta ON (lrwg_posts.ID = lrwg_postmeta.post_id) WHERE 1=1 AND ( lrwg_term_relationships.term_taxonomy_id IN (30,31) ) AND lrwg_posts.post_type = ‘events’ AND (lrwg_posts.post_status = ‘publish’ OR lrwg_posts.post_status = ‘private’) AND ( (lrwg_postmeta.meta_key = ‘end_date’ AND CAST(lrwg_postmeta.meta_value AS CHAR) < ‘20130618’) ) GROUP BY lrwg_posts.ID ORDER BY lrwg_posts.post_date DESC LIMIT 0, 10 [posts] => Array ( ) )
That is, the query is not actually returning any results.
(Also not that the custom field used now is end_date rather than event_end_date .)
AmirJune 19, 2013 at 3:32 pm #12865
I’ve emailed you the file. If you don’t receive it please send an email with the contact form so I can reply.
However, if the query isn’t returning any results there won’t be anything to map – you’ll need to get the query working first.
The SQL looked OK, so I would suggest checking that the correct term IDs are being used (30 and 31), as well as the post date, status, etc. of the posts you’re trying to select.
Here’s a link to the codex as well, in case there’s a clue there:
http://codex.wordpress.org/Class_Reference/WP_QueryJune 19, 2013 at 5:31 pm #12867
Thank you for the file. Sadly the issue still persists. The query must be incorrect as it’s not returning any results.
Just to confirm, “category_name=lachlan-catchment,rivers-creeks” by itself correctly lists normal post types with category “lachlan-catchment” and “rivers-creeks”.
In addition, query “post_type=events&meta_key=end_date&meta_value=20130618&meta_compare=<” by itself also correctly lists posts of type “events” where field “end_date” has a value less than (<) 20130618.
How would you combine the two queries to get a complete list containing posts from the first query together with “events” posts from the second query?
AmirJune 21, 2013 at 2:23 am #12879
I’m assuming you’re testing by printing wp_query directly with the PHP code I gave you, rather than trying to use MapPress, is that correct?
You combined the two queries correctly and they looked fine to me.
Of course, the combined query would only return events that are in the given categories AND have end_date < 20130618. Have you checked that you have posts that meet ALL of those criteria? Or are you instead trying to get the results for events in the given categories OR end_date < 20130618?June 21, 2013 at 5:32 am #12880
Yes I’m trying to get the result for normal posts in the given categories OR the events type posts with end_date<20130618. How would you write this query within the mashup tag?
Thanks. AmirJune 21, 2013 at 6:21 am #12881
Ok, I understand now. Unfortunately WordPress doesn’t support joining two different queries together with an OR condition like that.
One workaround might be to assign all of the posts you want to a specific category or tag, so you could query them as a single unit. For example, you could assign the posts of interest to tag ‘map’ and then query by that tag.
If you can come up with a query that will work to select those posts, I can explain how to map them:
http://codex.wordpress.org/Class_Reference/WP_QueryJune 23, 2013 at 1:05 pm #12890
Looks like I have to use a category to specify past events (and add it to the list of the other categories in the query) rather than filtering out “events” type posts by querying the value of “end_date” fields.
I appreciate all your help.
AmirNovember 29, 2013 at 4:08 am #13848zefyrParticipant
I have problem with call (in page template)
<?php echo do_shortcode('[mashup width="100%" height="350" query="posts_per_page=-1&post_type=post]'); ?>
It don´t show any POIs in the map.
I use WP 3.6 and Twenty twelve theme.
I have two different types of posts:
I use in posts custom fields for address:
map-adresa1 = Street and number
map-adresa2 = Town
map-adresa3 = State
I have assigned in the administration custom field to the
Map Custom Field
Address Line 1 map-adresa1
Address Line 2 map-adresa2
Address Line 3 map-adresa3
Where is the problem?November 29, 2013 at 6:38 am #13849
Before you can generate a mashup, you have to have the maps.
Did the plugin create maps for your posts? If not try publishing them – maps are created when a post is updated or published. You should see a map named ‘automatic’ is created for each post.
Once you have the maps, use ‘post_type=any’ instead of ‘post_type=posts’, otherwise WP will not read your custom post types.November 30, 2013 at 8:43 am #13856
Per our emails, I think this is resolved.
The mashup didn’t work because there was an incorrect query parameter: ‘post-type’ instead of ‘post_type’ in the template.
- You must be logged in to reply to this topic.