Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-sales domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the better-click-to-tweet domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-amazon domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pue-stats domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114

Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the wordpress-seo domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /home/staging-poc/public_html/wp-includes/functions.php on line 6114
Calling a list of all event categories | Event Espresso - Staging Server

Support

Home Forums Event Espresso Premium Calling a list of all event categories

Calling a list of all event categories

Posted: November 7, 2013 at 2:45 am

Viewing 4 reply threads


Zoe E

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?


Dean

  • Support Staff

November 7, 2013 at 2:50 am

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);
  • This reply was modified 11 years, 2 months ago by Dean. Reason: edited code


Zoe E

November 7, 2013 at 10:15 am

Cheers, I’ve done that. Here’s my code incase it’s useful to anyone else:

In functions.php:
function get_event_cats() {
global $wpdb;

$use_sql = “SELECT * FROM wp_events_category_detail”;
$thecats = $wpdb->get_results($use_sql);

$output = $output.”<ul class=\”menu-categories\”>”;
foreach ($thecats as $cat) :
$output = $output.”category_name.”\”>”.$cat->category_name.”“;
endforeach;
$output = $output.””;

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’].'”]’); ?>


Dean

  • Support Staff

November 8, 2013 at 1:45 am

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.


Zoe E

November 8, 2013 at 1:57 am

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 :)


Josh

November 8, 2013 at 7:11 am

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.

Viewing 4 reply threads

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.

Event Espresso - Staging Server