Support

Home Forums Event Espresso Premium Event archive page – HTML being output onto page

Event archive page – HTML being output onto page

Posted: September 4, 2018 at 1:35 pm

Viewing 11 reply threads


fishwinkmarketing

September 4, 2018 at 1:35 pm

Hi there!

On our event archive page, there is some HTML being output above each event title (see image below). How can we remove this so that the events appear properly?

Title not showing correctly

Also, how can we change the title of that page?

Thanks!


Josh

  • Support Staff

September 4, 2018 at 2:04 pm

Hi,

The trouble there with the HTML is a mistake in the WordPress theme. Somewhere the theme is using the_title() when instead it should use the_title_attribute(). There’s further explanation here.

If you need further help with correcting the code in the theme we’ll be glad to help, is there a way we can download a copy of it? The title of the page would also be generated by the theme so you’d likely make a modification to the theme in order to change the title of that page.


fishwinkmarketing

September 4, 2018 at 2:11 pm

Thanks for the quick reply. I would love some help getting this resolved. We are using the Zephyr theme. I’m not sure how to send you a copy of it. Any ideas?


Josh

  • Support Staff

September 4, 2018 at 2:30 pm

A dropbox link or similar works very well.


fishwinkmarketing

September 4, 2018 at 2:45 pm

Gotcha. Here’s the DL link ==> Theme

Thanks!


Josh

  • Support Staff

September 4, 2018 at 3:22 pm

To fix the html being output on the page, you’ll open the Zephyr theme’s framework/templates/blog/listing-post.php file, then on line 221 you’ll find this:
<a href="<?php echo $link; ?>"<?php echo $anchor_atts ?> aria-label="<?php the_title(); ?>">
and you’ll change it to this:
<a href="<?php echo $link; ?>"<?php echo $anchor_atts ?> aria-label="<?php the_title_attribute(); ?>">


Josh

  • Support Staff

September 4, 2018 at 3:27 pm

Then, to change the title of the event listing page, you can add the following filter function:

function my_theme_ee_archive_titles( $title ) {
    if ( is_post_type_archive('espresso_events') ) {
        $title = 'Upcoming Events';
    } 
    return $title;
}
add_filter( 'get_the_archive_title', 'my_theme_ee_archive_titles' );

The above will change the title to “Upcoming Events”, you can change the string to something else. You can add the above to a functions plugin or into your WordPress child theme’s functions.php file.

It may also help to contact the theme author and ask them to fix the usage of the_title() in the /listing-post.php file so you’ll have that fix going forward in future theme updates.


fishwinkmarketing

September 4, 2018 at 6:42 pm

Thanks a lot that worked perfectly!


fishwinkmarketing

September 4, 2018 at 6:55 pm

One last question on this. The title in the h1 tags now appears correct with that code. How do I get the page title in the head to match the updated title on the page?

Thanks!


Josh

  • Support Staff

September 4, 2018 at 7:49 pm

Do you mean what’s in the <title> tag? If so, you add this to your functions file:

/**
 * @param $title
 * @return array
 */
function my_custom_ee_archive_title(array $title) {
    global $post;
    if ( ! isset($post->post_type)) {
        return $title;
    }
    
    $type = $post->post_type;
    $types = [
        'espresso_events' => 'Your custom title here',
    ];
    if (is_archive() && isset($types[$type])) {
        unset($title); // comment out to preserve separator & site name
        $title['title'] = $types[$type];
    }
    return $title;
}
add_filter('document_title_parts', 'my_custom_ee_archive_title');


fishwinkmarketing

September 5, 2018 at 7:17 am

Yes, the title tag is what I meant, thanks. I added this code in and the title still remains “Archives: Events”. Any ideas?


Josh

  • Support Staff

September 5, 2018 at 7:43 am

Another plugin may be running a filter on the title tag and it’s overriding the other function. One way to possibly work around that is change the last line above to:
add_filter('document_title_parts', 'my_custom_ee_archive_title', 999);

Viewing 11 reply threads

The support post ‘Event archive page – HTML being output onto page’ 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