Support

Home Forums Event Espresso Premium the_title() not working

the_title() not working

Posted: January 12, 2016 at 9:50 am


Dallas REIG

January 12, 2016 at 9:50 am

It appears that the function of the_title() is no longer working properly. Not sure if this is intentional or a bug. If intentional, what can I replace this function with to get the name of the event to use as the title.

For example, this was the line of code I had in my content-espresso_events-details file:
ID; ?>” href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”>MORE INFORMATION

This now outputs as:
UpcomingREI EXPO 2016 โ€“ DALLAS”>MORE INFORMATION

As you can see something change that caused the_title() to output weirdly wrapping itself around the code in front of it. This was working before and outputting the title of the event.

Thanks in advance.


Dallas REIG

January 12, 2016 at 9:58 am

Sorry logic didn’t post right.

For example, this was the line of code I had in my content-espresso_events-details file:
<a class="more-information" id="a_event_title-<?php echo $post->ID; ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">MORE INFORMATION&nbsp;</a>

This now outputs as:
<a title="<span class=" class="more-information" id="a_event_title-4080" href="https://www.dallasreig.com/events/rei-expo-2016-dallas/" event-active-status-dtu"="" ee-status="">UpcomingREI EXPO 2016 โ€“ DALLAS">MORE INFORMATION&nbsp;</a>

As you can see something change that caused the_title() to output weirdly wrapping itself around the code in front of it. This was working before and outputting the title of the event.


Josh

  • Support Staff

January 12, 2016 at 10:11 am

Hi there,

It turns out this is not a bug in EE, it’s a mistake in your template code. This is because the_title() should never be used for a title attribute. This is because the_title() can have filters run on it to add extra html (in this case, it’s the Event Status that gets appended to the actual html title display).

The correct way to return the title for an html title attribute is use the_title_attribute().

https://codex.wordpress.org/Function_Reference/the_title_attribute


Dallas REIG

January 12, 2016 at 10:26 am

hmm it was working before but thanks, that works too. ๐Ÿ™‚


Josh

  • Support Staff

January 12, 2016 at 10:35 am

Sure it will work, but if anything uses the the_title() filter you’ll end up with unexpected output. The codex article I linked to explains more.

The support post ‘the_title() not working’ 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