it try to figure out, wich code i need to sho the categories for my list.
I used the custom template addon to create my list. I throw the select, because i want it as a list one after another. Category, below all events belonging to, and so on. So far so good.
It works with the event but not with the category of each event.
I can show the id of the category but not the title. Here’s my code, maybe one of you can help me with this.
`<?php
//Template: Event Listings Table
//Description: This template creates a list of events, displayed in a table. It can dipsplay events by category and/or maximum number of days.
//Shortcode Example: [EVENT_CUSTOM_VIEW template_name=”events-table”]
//Requirements: CSS skills to customize styles, some renaming of the table columns
//The end of the action name (example: “action_hook_espresso_custom_template_”) should match the name of the template. In this example, the last part the action name is “default”,
add_action(‘action_hook_espresso_custom_template_events-table’,’espresso_custom_template_events_table’);
function espresso_custom_template_events_table(){
global $this_event_id, $events, $wpdb;
//Get the categories
$sql = “SELECT * FROM ” . EVENTS_CATEGORY_TABLE;
$temp_cats = $wpdb->get_results($sql);
//Check for Multi Event Registration
$multi_reg = false;
if (function_exists(‘event_espresso_multi_reg_init’)) {
$multi_reg = true;
}
$cart_link = ”;
//Create an add to cart link
if ($multi_reg && $event_status == ‘ACTIVE’ && empty($externalURL)) {
$params = array(
//REQUIRED, the id of the event that needs to be added to the cart
‘event_id’ => $event->id,
//REQUIRED, Anchor of the link, can use text or image
‘anchor’ => __(“Add to Cart”, ‘event_espresso’), //’anchor’ => ”,
//REQUIRED, if not available at this point, use the next line before this array declaration
// $event_name = get_event_field(‘event_name’, EVENTS_DETAIL_TABLE, ‘ WHERE id = ‘ . $event_id);
‘event_name’ => $event->event_name,
//OPTIONAL, will place this term before the link
‘separator’ => ‘ ‘.__(“or”, ‘event_espresso’).’ ‘
);
Did you alter the code or copy the shortcode I provided and used that? Reason I ask is the forum editor has altered the quotation marks so the correct code would be:
$event_id is just a variable for holding the current Event ID, it is not global but as $event stores the ID (available through $event->id) it is not needed.
The support post ‘List of events separeted by 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.
Support forum for Event Espresso 3 and Event Espresso 4.