WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
conditional placeholder question (9 posts)

  1. clickmarketing
    Member
    Posted 2 years ago #

    I want to show a text only for today and future events and hide it from past events so I used the conditional placeholder {is_future}. However, it doesn't do the trick for today events. It treats it as past.

    Any idea how to do this correctly?

    Or can the {is_future} conditional placeholder include today events as well on the plugins nextupdate?

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

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    check your blog timezone, future is calculated according to the start day and time of the event.

  3. clickmarketing
    Member
    Posted 2 years ago #

    My blog timezone is correct. Is there a way to hide a text or a block of code if it is in the past?

  4. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    what about when you try to use is_past ?

  5. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    btw, just tested this and it works fine for me.

  6. clickmarketing
    Member
    Posted 2 years ago #

    I tried is_past. It also hides the text of the today event. I don't want it to do that. Text of today and future events I don't want to hide. Only the text of the past events.

  7. agelonwl
    Member
    Posted 2 years ago #

    Hope this snippet could help you; (modify as needed) paste to your theme functions

    usage:{is_today_future}..{/is_today_future}

    add_action('em_event_output_condition', 'my_em_styles_event_output_condition', 1, 4);
    function my_em_styles_event_output_condition($replacement, $condition, $match, $EM_Event){
        if( is_object($EM_Event) && preg_match('/^is_today_future$/',$condition, $matches) ){
            if( strtotime($EM_Event->event_start_date) >= strtotime(date("Y-m-d")) ){
                $replacement = preg_replace("/\{\/?$condition\}/", '', $match);
            }else{
                $replacement = '';
            }
        }
        return $replacement;
    }
  8. clickmarketing
    Member
    Posted 2 years ago #

    It works! Thanks for the code.

  9. agelonwl
    Member
    Posted 2 years ago #

    that's great.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic