Events Made Easy › Forums › How do I … › Including Events on WP Category Listing Pages
- This topic has 6 replies, 2 voices, and was last updated 12 years, 7 months ago by Anonymous.
-
AuthorPosts
-
Wed 28 Mar 2012 at 21:05 #43769AnonymousInactive
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"> </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"> </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?
Wed 28 Mar 2012 at 21:48 #49566FrankyKeymasterI never looked into wordpress categories myself, but if you say it works that’s ok 🙂
Wed 28 Mar 2012 at 21:55 #49567AnonymousInactiveYeah, 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.
Wed 28 Mar 2012 at 22:01 #49568FrankyKeymasterbtw, 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
Wed 28 Mar 2012 at 22:20 #49569AnonymousInactiveHmm, 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.
Wed 28 Mar 2012 at 22:21 #49570FrankyKeymasterShould be the same result, since the shortcode calls that function.
Thu 19 Apr 2012 at 20:16 #49571AnonymousInactiveI 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"> </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"> </div>
<h1>Other Posts in the Seminars Category</h1>
( ADDITIONAL ELSEIFs as NEEDED )
<?php else : ?>
<p></p>
<?php endif; ?> -
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.