Forums

Events Manager
Get startdate for current event (12 posts)

  1. bodaniel
    Member
    Posted 1 year ago #

    Hi,
    I have written a function in functions.php that takes a date as argument and prints titles of wordpress posts based on a custom field with the date set. This function works fine.
    What I want to do with this function is to show related wordpress posts in the event details for each event, based on startdate for the event (the date I set in the custom field in the posts).

    I hook this function to the event content like this:

    function my_em_custom_content($content){
      $content .= show_related_posts('<the_events_start_date>');
      return $content;
    }
    add_filter('em_content','my_em_custom_content');

    The problem is that I can't figure out how to get the startdate (<the_events_start_date>) for the current event? Is there some global class parameter I can call or who to get this?
    Please help!

    Thanks in advance
    / Daniel

    http://wordpress.org/extend/plugins/events-manager/

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    Yup,

    EM_Event::get(array('scope'=>'yyyy-mm-dd,yyyy-mm-dd'));

    for example would return an array of EM_Event objects between those two dates.

  3. bodaniel
    Member
    Posted 1 year ago #

    Thanks for the reply Marcus.
    This assumes that I know the date. But in my case the startdate will differ depending on what event the user is currently looking in to.
    So I need some way to get the startdate for the event instance currently beeing shown. Can I set global $EM_Event and get the startdate in some way?
    Hope you understand my issue.

    Thanks!
    / Daniel

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    $EM_Event should be global with the single event being shown (like with $post), so you could grab the start date.

    e.g. $EM_Event->start is a timestamp, so you can format that as needed.

  5. bodaniel
    Member
    Posted 1 year ago #

    Ok, I have tried that but I can't get it work :-(
    I have tested with this function but don't get any timestamp printed, only "hello world":

    function my_em_custom_content($content){
      $content .= $EM_Event->start . " hello world";
    	return $content;
    }
    add_filter('em_content','my_em_custom_content');
  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    you're missing

    global $EM_Event

  7. bodaniel
    Member
    Posted 1 year ago #

    Have tried that also, still no timestamp :-(

    function my_em_custom_content($content){
      global $EM_Event;
      $content .= $EM_Event->start . " hello world";
      return $content;
    }
    add_filter('em_content','my_em_custom_content');
  8. bodaniel
    Member
    Posted 1 year ago #

    My fault... It works fine now. :-)
    It didn't work on the particular event I was testing with, acctually I don't know why. But anyway I created another testevent and now it works fine! Thanks for your help!

    / Daniel

  9. bodaniel
    Member
    Posted 1 year ago #

    Now I figured out this:
    It works fine if I have multiple events the same day, and click on the particular event, then I can see the timestamp.
    But if I have only a single event on a day then I don't see the timestamp. But if I set this "Show list on day with single event?" in admin, then I have to click the particular event and than it works.

    Is there any way I can get "$EM_Event->start" for single events on a day without having to set "Show list on day with single event?" to yes in admin?

  10. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    if clicking on calendar days, you should take the relevant date from the $_REQUEST['calendar_day'] variable (part of the permalink with the date), and build a list using that date.

  11. bodaniel
    Member
    Posted 1 year ago #

    Hi,
    After upgrade to em 5 with permalinks set like "http://www.myurl.com/events/2012-01-26/" the request variable seems no longer be set? Do I have to get the date from the permalink URL or can I take it from some global parameter?
    Thanks in advance!

  12. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 1 year ago #

    you could try this:

    get_query_var('calendar_day')

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic