Use eo-loop-events template in custom page

WordPress Event Management, Calendars & Registration Forums General Question Use eo-loop-events template in custom page

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 5 years ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #33703

    I would like to be able to list upcoming events with the same formatting as is used for lists of events on category and venue pages, instead of in a plaintext list like the events list shortcode generates.

    I made a custom page template and added the following but it doesn’t load anything and is broken somehow, because the page after this point doesn’t load.

    <?php eo_get_template_part( 'eo-loop-events' ); //Lists the events ?>

    I also tried modifying the events list shortcode to use the same line, and it shows the formatting but each event just says “Nothing Found. Apologies, but no results were found for the requested archive.”

    I can’t tell where the list of events that the eo-loop-events template uses is actually loaded.

    How can I make a page for upcoming events that lists them like the events lists on the venue and category pages?

    Emma Azelborn
    #33815

    Hi Emma,

    The templates are intended for the ‘main loop’ of the page. You can trick WordPress into having multiple ‘main loops’ and then reset the query afterwards:

    query_posts(array(
        'post_type' => 'event',
        //...
    )); //not new WP_Query(), or eo_get_events()
    
    eo_get_template_part( 'eo-loop-events' );
    
    wp_reset_query();
    

    It’s generally not recommended to do this though. So you may prefer to just create your own templates that don’t use the ‘main query’, but a WP_Query instance.

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.