Support

Home Forums Event Espresso Premium Getting the Event Description for Custom Templating

Getting the Event Description for Custom Templating

Posted: August 24, 2016 at 4:34 pm


yamamDev

August 24, 2016 at 4:34 pm

Hello,

Im creating a custom single and archive view of the events. And im looking to print out the events details/description. I was looking through EE4 Theme Templates and Tags and found most the functions i needed, but I didnt see one for the description.

In the archive view, im using a WP_Query on the CPT espresso_events. and when I call the_excerpt() its working and giving me the event excerpt of the description. But in the single view when i call the_excerpt() it returns nothing. And when i call the_content() it prints out every aspect of the event from ticketing to venue details.

Looking to just print out the description.

Thank you!


Josh

  • Support Staff

August 25, 2016 at 7:21 am

Hi there,

You should be able to use the espresso_event_content_or_excerpt() template tag. If you add it to a template and it’s still outputting more than the description, it might help to add the following to your functions.php file:

add_filter( 'FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', '__return_false' );
add_filter( 'FHEE__EED_Event_Single__template_include__allow_custom_selected_template', '__return_false' );


yamamDev

August 25, 2016 at 7:55 am

I used that function call and added those lines to my functions.php and it is still printing out all the event details including ticket registration, all venue info, event time details and description.

Its the same as when i used the_content()


yamamDev

August 25, 2016 at 8:17 am

Im actually not getting the event description. The “details” i was seeing was the venue details. Is there a setting somewhere in the admin panel that im missing?


yamamDev

August 25, 2016 at 8:50 am

I wasnt starting the loop originally on the single template. Once i added the loop to the whole template the description came through.

But now im also getting the ticket registration bar and the date-time information. I still need the date time info, but im calling that separately later in the page.

Is there a filter or something that removes the date-time and ticket from the espresso_event_content_or_excerpt() call?


Josh

  • Support Staff

August 25, 2016 at 10:30 am

It all gets added with the_content() filters, but normally when you do a custom template, the extra content should not be output there. An alternative way to output the event description only is use one of the built in methods. Here’s an example:

<?php 
$event = EEH_Event_View::get_event( get_the_id() ); 
$event_desc = $event instanceof EE_Event ? $event->description_filtered() : ''; 
echo $event_desc;
?>


yamamDev

August 25, 2016 at 10:46 am

great! that worked like a charm. Thank you for all the help!

The support post ‘Getting the Event Description for Custom Templating’ 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