Posted: November 7, 2013 at 2:45 am
|
Hi, is there a way to call a list of all event categories? I want to automatically call all event categories and then assign a custom URL to them (ie /events/?cat=catname) that will automatically load a page of all applicable events (I have that bit covered). Any ideas on how we can call the list of cats please? |
|
Hi Zoe, The only way to grab all the categories would be via an SQL query: global $wpdb; //Get the categories $sql = "SELECT * FROM " . EVENTS_CATEGORY_TABLE; $categories = $wpdb->get_results($sql);
|
|
Cheers, I’ve done that. Here’s my code incase it’s useful to anyone else: In functions.php: $use_sql = “SELECT * FROM wp_events_category_detail”; $output = $output.”<ul class=\”menu-categories\”>”; return $output; I then created a new page template (page-event-cat.php), assigned it to a new page and place the following in the template (mine is outside the “while” for the page content): <?php echo do_shortcode(‘[EVENT_ESPRESSO_CATEGORY event_category_id=”‘.$_GET[‘catname’].'”]’); ?> |
|
Hi, Thanks for sharing your code. For future readers, please note it is probably best to use "SELECT * FROM " . EVENTS_CATEGORY_TABLE; rather than “SELECT * FROM wp_events_category_detail”; As your database may not use the wp_ prefix. |
|
Well spotted! Or I would normally use $wpdb->prefix to call the table prefit ahead of the table name. Is EVENTS_CATEGORY_TABLE a variable built in to event espresso? Is there a list of these anywhere for future reference? Cheers 🙂 |
Yeah, all of Event Espresso’s database tables are defined in espresso.php. If you look on line 246 in the current version you’ll see all them defined there. |
|
The support post ‘Calling a list of all event categories’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.