Support

Home Forums Event Espresso Premium Adding EE4 Category to theme Archive Title

Adding EE4 Category to theme Archive Title

Posted: December 3, 2015 at 12:25 pm


NHM

December 3, 2015 at 12:25 pm

Hello,

I have been researching around this topic for a while and I am hitting the wall of my php knowledge. I am using the Bridge theme by Qode and really like the layout of the EE category archive layout. However, the theme will only display “Archive” as the page title. I realize this is the theme and not EE.

I am modifying the title.php file provided by Qode in a child theme, with some code provided by them and some provided by you to another person in this support forum. I think I am close. Here is what the Qode template requests for the archive title


<span><?php qode_title_text(); ?></span>

In order to add a WP category to the category title they recommend this:


<span><?php if(is_tax('portfolio_category')){
echo single_cat_title();
} else {
qode_title_text();
}?>
</span>

I saw on another post here this code to add EE taxonomy code to the title of another themes archive page, but am having trouble reconciling the two (I know this is out of context):


<?php elseif ( 'espresso_events' == get_post_type() && is_tax( 'espresso_event_categories') ) :

$term_slug = get_query_var( 'term' );
$taxonomyName = get_query_var( 'taxonomy' );
$current_term = get_term_by( 'slug', $term_slug, $taxonomyName );

if ($current_term) {
?>
<h1 class="h-landmark"><span><?php echo $current_term->name; ?></span></h1>
<?php } ?>

<?php elseif ( is_archive('espresso_events') ): ?>

<h1 class="h-landmark"><span>CUSTOM EVENT LIST ARCHIVE TITLE</span></h1>

<?php endif; ?>

I anyone could be of help, this would solve so many problems I have been working around.

Thanks,

Dustin


Josh

  • Support Staff

December 3, 2015 at 7:10 pm

Hi Dustin,

I’m not 100% clear on what you’re asking for here. Is it that you want the name of the Event Category to appear where it normally says “Archive”?

If so, let’s stick with the first example. So in the first example, you have this:

<span><?php if(is_tax('portfolio_category')){
echo single_cat_title();
} else {
qode_title_text();
}?>
</span>

To add Event Espresso category names into the mix, you change it to this:

<span><?php if(is_tax('portfolio_category') || is_tax('espresso_event_categories')){
echo single_cat_title();
} else {
qode_title_text();
}?>
</span>

Or even simpler:

<span><?php if(is_tax()){
echo single_cat_title();
} else {
qode_title_text();
}?>
</span>

Bonus: If you want to display the category description too, you add this:

echo term_description( '', 'espresso_event_categories' );


NHM

December 7, 2015 at 5:27 pm

Thank you that is what I needed to know. Worked great.

The support post ‘Adding EE4 Category to theme Archive Title’ 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