Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @matthew99,
    If by “ongoing events” you mean my EM add-on “EM – Ongoing Events”, please redirect your question to the correct forum. 😉

    If you mean showing/altering the time of an event that is currently taking place? EM does not have a “Happening now” option. You could try and achieve that by creating a custom placeholder, checking the timespan. EM only checks the date and includes today either yes/no. (Setting: “Are current events past?”)

    Thread Starter matthew99

    (@matthew99)

    Yes, I meant showing/altering the time of an event that is currently taking place.
    Thank you for your answer 😉

    I was bored tonight, so I created this for you 😉

    function em_placeholder_happening_now($replacement, $EM_Event, $placeholder) {
      if($placeholder === "#_HAPPENINGNOW") {
        // Fetch the complete start & end timestamps (Y-m-d H:i:s) and convert them to an integer for comparison.
        $start = strtotime(get_post_meta($EM_Event->post_id, '_event_start', true));
        $end = strtotime(get_post_meta($EM_Event->post_id, '_event_end', true));
        $now = strtotime('now');
    
        // Check if the current time is after the start and before the end of this event.
        if( ($now > $start) && ($now < $end) ) {
          $replacement = "Happening now!";
        } else {
          $replacement = $EM_Event->output("#_EVENTDATES");
        }
      }
      return $replacement;
    }
    add_filter('em_event_output_placeholder', 'em_placeholder_happening_now', 10, 3);
    Thread Starter matthew99

    (@matthew99)

    Fantastic! I haven’t been here for a long time.
    Thank you @duisterdenhaag 😉

    • This reply was modified 6 years, 3 months ago by matthew99.
    Thread Starter matthew99

    (@matthew99)

    Hi @duisterdenhaag

    I have tried many files (I watched the tutorial) but the script does’t work.

    I have tried many files

    What files?

    Just paste in your theme’s functions.php or simply use https://ww.wp.xz.cn/plugins/code-snippets/

    Thread Starter matthew99

    (@matthew99)

    I did everything again and it works. Thank you 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Format “Now”’ is closed to new replies.