Support

Home Forums Event Espresso Premium Ouput all category names

Ouput all category names

Posted: October 22, 2013 at 5:32 am

Viewing 3 reply threads


David

October 22, 2013 at 5:32 am

How would I output all my category names as a list in a php template?

Also can I output all ‘Unique Category Identifiers’ in PHP?

Thanks
Geoff


Dean

October 23, 2013 at 12:44 am

Hi Geoff,

I don’t believe we have any shortcodes to do this, but if you are doing it via PHP, then a short SQL query might work for you:

	$sql = "SELECT * FROM " . EVENTS_CATEGORY_TABLE;
	$categoryarray = $wpdb->get_results($sql);

That will give you an array of the category table, then just use a foreach loop to go through it and out put what you need.


David

October 24, 2013 at 4:44 am

Hi Dean
Thank you for that.
I would now like to use the ‘Unique Category Identifiers’ as class names in my espresso_table so that I can filter the list by using checkboxes instead of the category name. This is what I have at the moment in espresso_table.php
<tr class="espresso-table-row <?php echo do_shortcode('[CATEGORY_NAME event_id="'.$event->id.'"]');?>">

How do I query the table and return the correct categories for each event in-place of the shortcode?

This is what I have so far.

<code>$sql = &quot;SELECT category_identifier FROM &quot; . EVENTS_CATEGORY_TABLE;
$categoryarray = $wpdb-&gt;get_results($sql);

foreach ($categoryarray as $option) {
echo $option-&gt;category_identifier;
}</code>

Thanks Geoff


Dean

October 24, 2013 at 5:59 am

Hi Geoff,

If you are looking for a table with a category filter, you may want to hang fire, as we are going to release (hopefully very soon) an add on that has a table that the the user can filter by categories. (This may be a separate purchase or part of a licence nothing has been decided on that so please be aware it may cost). sneak peak – http://d.pr/i/Uatn

However if you are just wanting to manually filter the list, you could query the $event array. Each $event array contains the category ID’s associated with that event. Then you would need to either query the database to pull the category name via the ID or just continue using the shortcode as that works well and is simple enough.

Viewing 3 reply threads

The support post ‘Ouput all category names’ 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