Templates

I’ve had a couple of queries about “templates” or “template tags”.

Yes you can do it, but first some thoughts:

I think the list types give you the template type control without all the hassle of coding and testing yourself.   They’ve been around a while now and are pretty stable.

Using a theme template  has disadvantages

  • change the theme – lose the events listing
  • must use a child theme to avoid being overwritten on updates.  These means you “fix” the css and do not get the updated css if the main theme is updated.
  • the theme is now dependant on the plugin.

I’d suggest if you must code yourself and want access to the event data, then write a  pluggable function instead. See an example here (scroll down)

If you really want to  write your own calendar list template under the theme (rather than a separate plugin with the pluggable function) , you can still achieve it with the self same pluggable function and a simple ‘do_shortcode’:

 

In your calendar page template:

function amr_list_events() {
your listing code here - see the example
}

echo do_shortcode('[events]');

The shortcode logic will do all the event preparation  for you, explode out the recurring entries, check start and end dates within limits, until date limits etc as well as any parameters passed via the query line for navigation etc.

The events array will then be passed to the listing function with the events sorted in date and time order.

After that, it’s all yours…..

 

 

Note:You can do this with [eventinfo] too.

 

Leave a Reply