Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active March 28, 2024 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/25705b6b4fd3ad3f706330304fca62fb to your computer and use it in GitHub Desktop.
Save Pebblo/25705b6b4fd3ad3f706330304fca62fb to your computer and use it in GitHub Desktop.
Example of how to change the archive title to remove 'Archive: ' and dynamically display the events slug set in settings
<?php //Please do not include the opening PHP tag if you alreayd have one.
function tw_ee_get_the_archive_title($title) {
if(is_post_type_archive('espresso_events')) {
if(class_exists('EE_Registry')){
$event_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
return ucfirst($event_slug);
}
}
return $title;
}
add_filter( 'get_the_archive_title', 'tw_ee_get_the_archive_title', 20, 1 );
<?php //Please do not include the opening PHP tag if you alreayd have one.
function tw_ee_get_the_archive_title_hardcoded($title) {
if(is_post_type_archive('espresso_events')) {
return 'Current Events';
}
return $title;
}
add_filter( 'get_the_archive_title', 'tw_ee_get_the_archive_title_hardcoded', 20, 1 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment