Created
May 15, 2014 15:15
-
-
Save joshfeck/d1e3446d78f4a16775cb to your computer and use it in GitHub Desktop.
Adds the event name to the meta page title tag. Requires Event Espresso 3. Outputs: "{Event Name} | {Site Name}"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // remove this line if your functions file already has an opening PHP tag | |
/** | |
* Creates a nicely formatted and more specific title element text | |
* for output in head of document, based on current event. | |
* | |
*/ | |
function ee_reg_page_title( $title, $sep ) { | |
// only do stuff if espresso_get_event exists | |
if ( function_exists('espresso_get_event') ) { | |
global $this_event_id; | |
if (isset($this_event_id) && !empty($this_event_id)){ | |
$event_id = $this_event_id; | |
} | |
if ( empty( $event_id ) ) return $title ; //get out this isn't an ee page. | |
$event = espresso_get_event( $event_id ); | |
//one more sanity check | |
if ( empty( $event ) ) return $title; //get out we don't have an event. | |
if ( $event_id ) { // if there's an event id...do stuff... | |
$event = espresso_get_event( $event_id ); | |
$title = ''; | |
// Add the site name. | |
$title .= get_bloginfo( 'name' ); | |
$title = "$event->event_name $sep $title"; | |
return $title; | |
} | |
} | |
} | |
add_action( 'action_hook_espresso_social_display_buttons', 'ee_mod_page_title'); | |
function ee_mod_page_title() { | |
add_filter( 'wp_title', 'ee_reg_page_title', 10, 2 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment