Events Made Easy Forums How do I … Including Events on WP Category Listing Pages

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #43769
    Anonymous
    Inactive

    I’ve kludged up a way to do this. I’m a complete php novice, but I think this works. Please tell me if I’m on the right track here.

    I copied archive.php to a new category.php file, and included this above the loop. The key here was discovering the “do shortcode” function.

    <!-- MODIFIED 3/2012 TO INCORPORATE EME EVENTS MADE EASY CATEGORIES INTO WP CATEGORY LISTINGS -->
    <?php if (is_category('Fun Events')) : ?>
    <h1>Fun Events in the Calendar</h1><?php echo do_shortcode('[events_list category=2 paging=1 limit=10 scope=month]'); ?>
    <div class="sep">&nbsp;</div>
    <h1>Other Posts in the Fun Events Category</h1>
    <?php elseif (is_category('Seminars')) : ?>
    <h1>Seminars in the Calendar</h1><?php echo do_shortcode('[events_list category=3 paging=1 limit=10 scope=month]'); ?>
    <div class="sep">&nbsp;</div>
    <h1>Other Posts in the Seminars Category</h1>

    ( ADDITIONAL ELSEIFs as NEEDED )

    <?php else : ?>
    <p></p>
    <?php endif; ?>

    This is important to my site because we based so many prior events on WP Categories (using an old version of The Events Calendar in which events were posts), and we rely on category listings. All I have to do is map all my pre-existing WP Category names to corresponding Category numbers in the EME system…

    What do you think, Franky?

    #49566
    Franky
    Keymaster

    I never looked into wordpress categories myself, but if you say it works that’s ok 🙂

    #49567
    Anonymous
    Inactive

    Yeah, the WP Menus dashboard practically invited us to base the site around categories…

    I just finished mapping all of them (had to use on one of them because it contained a single quote mark).

    It’s working beautifully right now. (Though I would rather have found a category variable than having to re-enter each category name in the IF THEN structure.) I thought this technique would be worth sharing!

    Thanks for the feedback.

    #49568
    Franky
    Keymaster

    btw, do you know you can call the function eme_get_events_list instead of doing the “do_shortcode”? See http://www.e-dynamics.be/wordpress/?cat=22

    #49569
    Anonymous
    Inactive

    Hmm, no I didn’t know that. Is that way better or more efficient (CPU or otherwise)?

    I tried it and the result is nearly identical, except your way ends up with a bit less vertical space between my < h1 > title and the first event listing.

    #49570
    Franky
    Keymaster

    Should be the same result, since the shortcode calls that function.

    #49571
    Anonymous
    Inactive

    I just noticed that “scope=month” seems to be the WRONG syntax, and that I’m not getting paging properly at all. I think it ended up just defaulting to “FUTURE” events. I needed to have limit=0 and scope=this_month.

    So following is a fixed version of the above code.

    <!-- MODIFIED 3/2012 TO INCORPORATE EME EVENTS MADE EASY CATEGORIES INTO WP CATEGORY LISTINGS -->
    <?php if (is_category('Fun Events')) : ?>
    <h1>Fun Events in the Calendar</h1><?php echo do_shortcode('[events_list category=2 paging=1 limit=0 scope=this_month]'); ?>
    <div class="sep">&nbsp;</div>
    <h1>Other Posts in the Fun Events Category</h1>
    <?php elseif (is_category('Seminars')) : ?>
    <h1>Seminars in the Calendar</h1><?php echo do_shortcode('[events_list category=3 paging=1 limit=0 scope=this_month]'); ?>
    <div class="sep">&nbsp;</div>
    <h1>Other Posts in the Seminars Category</h1>

    ( ADDITIONAL ELSEIFs as NEEDED )

    <?php else : ?>
    <p></p>
    <?php endif; ?>

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top