• Resolved Nick

    (@nickbits)


    Hi,

    I have attempted to create a custom template. As a test I have single-mec-events.php printing a few widgets:

    get_header(); ?>
    
    <div id="primary" class="content-area">
        <main id="main" class="site-main">
    
            <?php while ( have_posts() ) : the_post(); ?>
                
                <?php
                $single = new MEC_skin_single();
                $single_event_main = $single->get_event_mec(get_the_ID());
                $single_event_obj = $single_event_main[0];
    
                $single->display_cost_widget($single_event_obj);
                $single->display_category_widget($single_event_obj);
                $single->display_date_widget($single_event_obj);
                $single->display_time_widget($single_event_obj);
                $single->display_location_widget($single_event_obj); // Show Location
                ?>
    
                <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
                <?php the_content(); ?>
                </article>
    
            <?php endwhile; ?>
    
        </main>
    </div>
    
    <?php get_footer();

    This is just a test, all works as expected except for display_date_widget which doesn’t return the date. I have attempted to debug and on following through and looking in display_date_widget (app/skins/single.php) I see that $this->date_format1 is null. The date format is set, in settings to ‘d M Y’. So the question is, am I missing something here or is this a bug?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Nick

    (@nickbits)

    Hi,

    The only way I can get this to work, without changing the plugin code is to call initialize so we have:

    ...
    $single = new MEC_skin_single();
    $single->initialize(array('id'=>get_the_ID()));
    $single_event_main = $single->get_event_mec(get_the_ID());
    ...

    That isn’t shown on the info page for it
    https://webnus.net/dox/modern-events-calendar/overriding-mec-single-event-page/ so assume either that step is missing from the info page or there is a bug and ‘date_format1’ is not being set.

    Plugin Contributor webnus

    (@webnus)

    Hello @nickbits,

    Thank you for your report,
    This is forwarded to the developer team and it will be fixed for the next update.

    For now, your solution is the best solution to showing the date widget,
    About date format, you can head over to MEC Settings > Single Event Page > Single Event Date Format and set your desired format.

    Best Regards

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

The topic ‘display_date_widget not returning correct value’ is closed to new replies.