• Resolved Ross Wintle

    (@magicroundabout)


    Hi guys,

    The basic thing I want to do is apply a page template (e.g. with a specific widget area) to the event-list page for a category.

    This works for the general events page as the events “Page” exists in WordPress and has a page template. But the event list for a category seems to be a taxononmy archive.

    I’ve tried creating taxonomy-event-categories.php and this seems to be a step forward, but it had no content.

    I then added the em_events() template tag, but it produces an unfiltered list of ALL events, not the list of events from the category.

    Is there either:
    – A template tag for displaying the correct list
    – A way to pass through the query args from the page to the em_events() call?
    – A better way to do this?

    Thanks

    Ross

    http://wordpress.org/plugins/events-manager/

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hiya,

    You can do this and will need to create a specific template as per http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display

    I believe your use of “taxonomy-event-categories.php” was slightly incorrect. Rather, it should be taxonomy-event_categories.php (note the underscore)

    Thanks,
    Phil

    Thread Starter Ross Wintle

    (@magicroundabout)

    Thanks Philip.

    I understand the Template Hierarchy. And as far as I can tell it has a hyphen, not an underscore. See http://plugins.svn.wordpress.org/events-manager/tags/5.5.2/em-posts.php, line 5 for the definition of the name of the type.

    I’ve created the correct template and confirmed that code that I put in that template is displayed when I view the archive for the term.

    What I want to know is if this is the correct mechanism for doing what I’m trying to do, or is there a better way. And if it is, what do I need to put in that template to get the list of events correctly.

    I’ve got it working with:

    $cat = get_queried_object();
    em_events(array('category' => $cat->term_id));

    But this isn’t ideal as it only passes the category to em_events. It doesn’t pass any other query args.

    Still looking for a better way!

    Ross

    Hi Ross,

    If you create a custom template file by copying your category template and renaming it taxonomy-event-categories.php, that should work without needing any custom code.

    If it doesn’t, try doing the same with the default WordPress theme to check there’s nothing wrong with your custom theme.

    Thread Starter Ross Wintle

    (@magicroundabout)

    Thanks.

    OK. Looks like there IS a problem with the theme. But what? What does Events Manager hook into to print the event details?

    Thread Starter Ross Wintle

    (@magicroundabout)

    OK, this is REALLY weird. I think I must have discovered a bug. I’ve managed to replicate the same issue with the Twenty Twelve theme. So it’s either a bug, or something weird in my EM settings.

    If I create a taxonomy-event-categories.php and put, at the very top, before any other code:

    if (have_posts()) { echo "Yes" }

    I don’t get yes echo’ed. So there are no posts in the query.

    If I remove the taxonomy-event-categories.php file, then the event list for the category seems to use page.php. And if I edit page.php to add the debugging code (shown above) to the header, then I get the “Yes” echo’ed.

    Why does the content of the query change if I have a taxonomy-event-categories.php file?!

    I can replicate this with the Twenty Twelve theme. If I switch themes then, initially, it’s OK – my event archive for the category displays fine. But if I take a copy of page.php and call that copy taxonomy-event-categories.php, the event archive for the category becomes empty.

    Can someone confirm if this can be replicated. Can someone from the plugin support team see if this is a bug that got introduced at some point? I think this used to work, so perhaps a recent update broke something?

    Plugin Support angelo_nwl

    (@angelo_nwl)

    have you tried something like this?

    <?php
    	$queried_object = get_queried_object();
    	$term_id = $queried_object->term_id;
    
    	$EM_Category = em_get_category($term_id);
    ?>
    
    <h1><?php echo $EM_Category->output('#_CATEGORYNAME'); ?></h1>
    <p><?php echo $EM_Category->output('#_CATEGORYNEXTEVENTS'); ?></p>
    Thread Starter Ross Wintle

    (@magicroundabout)

    Yeah, I’ve got a simple workaround along these lines (see above), but I’m not convinced it’s the best way – it only passes the event category from the query args, not any other parameters.

    I’d rather understand what’s going on and try to get it fixed if possible.

    I’d have a look into the code but I don’t have time right now. Wondered if this was a known issue or something the developers could look into – especially as I can re-create it in Twenty Twelve.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Customising category-specific event-list page’ is closed to new replies.