Mashup shortcode to show by event date

Home Forums MapPress Support Mashup shortcode to show by event date

Tagged: , ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12725
    amir200770
    Participant

      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.

      #12726
      BradSiegfried
      Participant

        Maybe a typo on “&meta_comapare”?

        #12727
        amir200770
        Participant

          BradSiegfried,

          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?

          #12728
          Chris
          Keymaster

            Hi,

            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-documentation

            #12729
            amir200770
            Participant

              Hi 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.

              #12730
              Chris
              Keymaster

                Hi,

                Something like:
                $query = “post_type=events&meta_key=event_end_date&meta_value=” . date(‘Ymd’) . “&meta_compare=’<'"; do_shortcode('[mashup query="' . $query . '"]');

                #12731
                amir200770
                Participant

                  Hi 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?

                  #12735
                  amir200770
                  Participant

                    Hi 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.

                  Viewing 8 posts - 1 through 8 (of 8 total)
                  • You must be logged in to reply to this topic.