Home › Forums › MapPress Support › Mashup shortcode to show by event date
- This topic has 7 replies, 3 voices, and was last updated 9 years, 8 months ago by
amir200770.
-
AuthorPosts
-
May 31, 2013 at 7:40 pm #12725
Hi Chris,
I have purchased MapPress Pro and it’s by far the best Map plugin for WordPress. Thank you and job well done.
I have a custom post type “Events” with a custom field “Event End Date”. The following shortcode
[mashup width="100%" height="400" query="post_type=events&meta_key=event_end_date&meta_value=20130311"]
correctly outputs the POIs with Event End Date = 11/03/2013.
However, the following shortcode
[mashup width="100%" height="400" query="post_type=events&meta_key=event_end_date&meta_value=date('Ymd')&meta_comapare='<'"]
outputs nothing. I am trying to show all POIs where the Event End Date field value is less than today (i.e. show past events on the map).
What is wrong with this code?
Thank you in advance.
June 1, 2013 at 5:48 am #12726Maybe a typo on “&meta_comapare”?
June 1, 2013 at 9:00 am #12727BradSiegfried,
Thank you for getting back to me. Sadly this was just a type here in the forums. The correct spelling of “meta_compare” still does not work.
Can anyone assist please?
June 1, 2013 at 9:57 am #12728Hi,
I think the problem is that you can’t put PHP statements like date(‘Ymd’) into a shortcode.
You could instead insert a do_shortcode() statement into your template. There’s a simple example here that you could modify to include the current date:
http://mappresspro.com/mappress-documentationJune 1, 2013 at 11:14 am #12729Hi Chris,
Thank you for getting back to me. I am aware of the use of do_shortcode within the PHP code and am already using it in other places. However, how would you write something like
echo do_shortcode(‘[mashup width="100%" height="400" query="post_type=events&meta_key=event_end_date&meta_value=date('Ymd')&meta_compare='<'"]‘);
because this statement clearly has incorrect syntax.
Thanks.
June 1, 2013 at 11:53 am #12730Hi,
Something like:
$query = “post_type=events&meta_key=event_end_date&meta_value=” . date(‘Ymd’) . “&meta_compare=’<'"; do_shortcode('[mashup query="' . $query . '"]');June 1, 2013 at 12:00 pm #12731Hi Chris,
Thanks for that. I just tried the following
$query = “post_type=events&meta_key=event_end_date&meta_value=” . date(‘Ymd’) . “&meta_compare='<‘”;
echo do_shortcode(‘[mashup width="100%" height="400" query="' . $query .'"]‘);and unfortunately it still returns no POIs (just a map of the globe). And I definitely have events with event_end_date < date(Ymd).
It’s almost as if the shortcode does not understand date(Ymd) or meta_compare.
Any thoughts?
June 1, 2013 at 4:42 pm #12735Hi Chris,
I have managed to get it to work. The meta_compare value should not appear in quotes. So the query statement should just be
$query = “post_type=events&meta_key=event_end_date&meta_value=” . date(‘Ymd’) . “&meta_compare=<“;
That is < instead of ‘<‘.
Thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.