[EventCalendar] Customising ec3_get_events display

Alex Tingle alex at firetree.net
Mon Dec 22 15:41:50 UTC 2008

On 22 Dec 2008, at 12:26, James Kirsop wrote:
>> Second question:
>>>> Or, is there a way of ordering posts output by the general  
>>>> Wordpress loop in an order dictated by their event dates set in  
>>>> ec3?. Running the usual/standard wordpress loop doesn't help  
>>>> much, as they just appear in the date order that they were posted  
>>>> in -- which is not what I'm looking for. Ideally, I'd like to  
>>>> have pagination working, which isn't covered by ec3_get_events()  
>>>> but is covered by the WP loop.
>> May I refer you to the documentation.
>> "Keep Events Separate" mode sorts the event category page in the  
>> way you want:
>> http://wpcal.firetree.net/options/
> The problem is, I want to be able to sort posts based on what  
> wordpress categories (other than the event category) they're in --  
> without needing to use the ?ec3_listing=events function as all the  
> posts on the site will be events. EG. I'd like to be able to send  
> users to http://domain.com/archives/categories/<categoryname> and  
> give them a list of events within that category in the order that  
> the events are occurring in, which I assume is what the advanced- 
> query ?ec3_listing=events does. This allows me to group events into  
> certain types, so that they're easy to navigate for users of the  
> site I'm working on. Obviously all the events need to go into the  
> events category -- but since my site is going to purely be for  
> listing events (more or less like a calendar/diary), it would be  
> really nice to be able to sort the events based on their date, and  
> the category they're in -- and have the 'ordered by date' listing  
> work no matter where they are in the site.

You could just add the GET parameter ec3_listing=events into the  
ReWrite rule in your .htaccess file.

Alternatively, you could try this simple plug-in:

Plugin Name: EC3 Events Only
Version: 1.0
Plugin URI: http://wpcal.firetree.net
Description: Requires EC3. Makes all queries event
Author: Alex Tingle
Author URI: http://blog.firetree.net/

/** Force default query to be ec3_listing=EVENTS. */
function EC3EO_filter_parse_query(&$wp_query)
     $wp_query->ec3_listing = 'EVENTS';

// Make sure the filter runs *after* EC3's.
add_filter('parse_query', 'EC3EO_filter_parse_query', 11);


>> If you need finer control, then have a look at the advanced queries:
>> http://wpcal.firetree.net/advanced-queries/
> Some of these are great, but require some tweaking for what I'm  
> looking for. Eg. I'd like to show events from 'This Week' -- which  
> shows events from the Sunday before the current date, to the sunday  
> following the current date -- as opposed to showing the 'next 7  
> days' which is what I've been using as a substitute until I work out  
> how to get the desired listing.

You should be able to do that with a custom query. Calculate your  
start and end dates and then use something like:


You can use query_posts() to drive a main loop, but it's best to make  
your own query object for a sidebar...

   $query = new WP_Query();

Look at the implementation of ec3_get_events() in template-functions- 
new.phph for a fully worked out example.

>> Serious question: Did you read the documentation and not see how  
>> those features might help you, or did you not find the  
>> documentation? Either way, it's not helped you as it should have.
> I did read the documentation, and as you can see from my post above  
> -- the options page didn't really provide the answers I was looking  
> for. The advanced queries page was a great place to get me started  
> on working out how I can add my own custom functionality to ec3 --  
> but I haven't made much progress with that yet. I think the  
> documentation is fine (perhaps a little bit bare though, could  
> perhaps do with some padding out/more explainations of particular  
> things), but was outside the scope of what I'm looking for in this  
> plugin.

OK, thanks. I try to keep the docs terse, otherwise no one will bother  
to read them. More examples would be good though.


More information about the EventCalendar mailing list