Support

Home Forums Event Espresso Premium Single event page – Can't target event description

Single event page – Can't target event description

Posted: January 28, 2021 at 10:53 am

Viewing 7 reply threads


ComedieTriomphe

January 28, 2021 at 10:53 am

Hi,

I am currently editing my theme’s single.php in order to design the single events page, and doing all of this in my child theme.

I know EE hooks into the_content() to display its template. I want to display my event description as well as its featured image side by side and would normally use a flexbox container to do that.
I’m trying to identify and select the event description container, and ONLY that one. My logical solution was that content-espresso_event-details.php was in charge of displaying this info because it is the one creating the <div class="event-content"> which I see with the inspector is the one displaying the event’s description. Yet, if I use

<?php espresso_get_template_part( 'content', 'espresso_events-details' ); ?>

in my single.php file I end up with


<div class="event-content">
<div class="event-datetimes">...</div>
...
</div>

I end up with all the other elements such as datetimes and ticket selector nested under the event-content div. The description’s text doesn’t belong to any container anymore.

If I do the same thing but this time with

<?php espresso_get_template_part( 'content', 'espresso_events-datetimes' ); ?>

I get the result expected and can display the datetimes template out.

What am I doing wrong here?


ComedieTriomphe

January 28, 2021 at 11:01 am

Here is a better looking code on pastebin:

https://pastebin.com/tWwPRUxN

To note, I have the display selector activated in admin.

Here is a link to a single event page:

https://www.comedietriomphe.fr/events/ce-soir-cest-sushis/


Tony

  • Support Staff

January 28, 2021 at 2:11 pm

Hi there,

Did you create a copy of your single.php template and name it single-espresso_events.php as per the template hierarchy?

https://developer.wordpress.org/themes/basics/template-hierarchy/

Or have you added a conditional to your single.php template file to output specifically for EE events?

I’m guessing the latter as then by default EE won’t inject the additional details into the_conent() as it is expected that you will be takin over the output, but before moving forward can you let me know where that above code is located?


ComedieTriomphe

January 29, 2021 at 2:02 am

Hi Tony,

At this stage, I’m using the single.php template. Our website doesn’t have any other type of posts than events, we use pages for the rest, so I thought I could simply edit that one.
I’m not sure what you mean by adding a conditional: I haven’t added any EE code into the single.php template. Arabica’s template code gets loaded where the_content() is located in single.php.

Let me know what are your thoughts!


Tony

  • Support Staff

January 29, 2021 at 4:09 am

At this stage, I’m using the single.php template. Our website doesn’t have any other type of posts than events, we use pages for the rest, so I thought I could simply edit that one.

You ‘can’ just edit single.php, however, Event Espresso explicitly checks for single-espresso_events.php before injecting additional details into the_content(), so if you want to take full control of the output just use that template file.

I’m not sure what you mean by adding a conditional: I haven’t added any EE code into the single.php template.

A conditional such as:

if ( 'espresso_events' == get_post_type() ) { // Output stuff spcicially for EE event }

Or:

if ( is_singular( 'espresso_events' ) ) {
    // conditional content.
}

Using single-espresso_events.php avoids the need for this as it will only be loaded for EE events.

You said you haven’t added any code, but in your opening post, you state your adding code? See:

Yet, if I use

in my single.php file I end up with


ComedieTriomphe

January 29, 2021 at 5:51 am

Hi Tony,

Ok, I have started using the single-espresso_events.php.

This doesn’t help me with my original issue: I still can’t select the event’s description.
Have a look at the inspector using the original content-espresso_events-details.php with an added HELLO WORLD. You’ll see the description is part of the event-content div (<p> tags). I need to get this description out of the event-content div so that I can have it in another container which I design side-by-side with featured image. What do you suggest?


Tony

  • Support Staff

January 29, 2021 at 12:18 pm

Within single-espresso_events.php the_content() would not call all of the other sections so I assume your using <?php espresso_get_template_part( 'content', 'espresso_events-details' ); ?>?

Can you share your single-espresso_events.php template file, please?

To get the event description within that template you just need to call the_content().


ComedieTriomphe

February 1, 2021 at 10:42 am

Hi,

I solved this over the weekend! My issue was that I had the filters in my child theme’s function.php from this resource
When calling echo espresso_event_content_or_excerpt( 55, null, false ); it would inject all the elements but as soon as I got rid of the above filters I could use the same fonction to get the description!

All good now, thank you!

Viewing 7 reply threads

The support post ‘Single event page – Can't target event description’ 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