Skip to content

Instantly share code, notes, and snippets.

@tamarazuk
Last active December 27, 2015 10:29
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 tamarazuk/ab3e098fd06ab772f3aa to your computer and use it in GitHub Desktop.
Save tamarazuk/ab3e098fd06ab772f3aa to your computer and use it in GitHub Desktop.
PressCore The7 theme with The Events Calendar - Page title
<?php
// Use this if you want to have the page title appear but would like to alter the title in some way.
function namespace_tribe_page_title_controller($title, $title_template) {
// General check for any Tribe page
if ( namespace_is_tribe() ) {
$title = "Your title here";
}
// Or more specific checks
if( tribe_is_month() && !is_tax() ) { // Month View Page
$title = "We're on the month view page";
} elseif ( tribe_is_month() && is_tax() ) { // Month View Category Page
$title = "We're on the month view category page";
} elseif( tribe_is_past() || tribe_is_upcoming() && !is_tax() ) { // List View Page
$title = "We're on the list view page";
} elseif( tribe_is_past() || tribe_is_upcoming() && is_tax() ) { // List View Category Page
$title = "We're on an list view category page";
} elseif( tribe_is_week() && !is_tax() ) { // Week View Page
$title = "We're the week view page";
} elseif( tribe_is_week() && is_tax() ) { // Week View Category Page
$title = "We're the week view category page";
} elseif( tribe_is_day() && !is_tax() ) { // Day View Page
$title = "We're on the day view page";
} elseif( tribe_is_day() && is_tax() ) { // Day View Category Page
$title = "We're on a day view category page";
} elseif( tribe_is_map() && !is_tax() ) { // Map View Page
$title = "We're on the map view page";
} elseif( tribe_is_map() && is_tax() ) { // Map View Category Page
$title = "We're on the map view category page";
} elseif( tribe_is_photo() && !is_tax() ) { // Photo View Page
$title = "We're on the photo view page";
} elseif( tribe_is_photo() && is_tax() ) { // Photo View Category Page
$title = "We're on the photo view category page";
} elseif( tribe_is_event() && is_single() ) { // Single Events
$title = "We're on a single event page";
} elseif( tribe_is_venue() ) { // Single Venues
$title = "We're on a single venue page";
} elseif( get_post_type() == 'tribe_organizer' && is_single() ) { // Single Organizers
$title = "We're on a single organizer page";
} else {
// don't want to do anything here so the theme can do it's thing
}
return sprintf( $title_template, $title );
}
add_filter('presscore_page_title', 'namespace_tribe_page_title_controller', 10, 2);
function namespace_is_tribe_archive() {
$is_tribe_archive = false;
if ( function_exists('tribe_is_event') ) {
$is_tribe_archive = tribe_is_month() || tribe_is_past() || tribe_is_upcoming();
}
if ( ! $is_tribe_archive && function_exists('tribe_is_week') ) { //PRO version only - ensures no fatal errors if not active -- no need to keep checking if already true
$is_tribe_archive = $is_tribe_archive || tribe_is_week() || tribe_is_day() || tribe_is_map() || tribe_is_photo();
}
return $is_tribe_archive;
}
function namespace_is_tribe_single() {
$obj_id = get_queried_object_id();
if ( function_exists('tribe_is_event') ) {
return tribe_is_event($obj_id) || tribe_is_venue($obj_id) || get_post_type() == 'tribe_organizer';
} else {
return false;
}
}
function namespace_is_tribe() {
return namespace_is_tribe_archive() || namespace_is_tribe_single();
}
/* Use this to hide the page title on all Tribe Events pages */
body[class^="tribe-events-"] .page-title,
body[class*=" tribe-events-"] .page-title {
display: none;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment