Advertisement
mikelittle

Swap 2012 title format

May 4th, 2013
1,161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. add_action( 'after_setup_theme', 'z1_turnoff_twentytwelve_title' );
  3. function z1_turnoff_twentytwelve_title() {
  4.     remove_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );
  5. }
  6.  
  7. add_filter( 'wp_title', 'z1_twentytwelve_wp_title', 10, 2 );
  8. function z1_twentytwelve_wp_title( $title, $sep ) {
  9.     global $paged, $page;
  10.  
  11.     if ( is_feed() )
  12.         return $title;
  13.  
  14.     //strip out separator already added by wp_title()
  15.     $title = str_replace( $sep, '', $title);
  16.  
  17.     // Add the site description for the home/front page.
  18.     $site_description = get_bloginfo( 'description', 'display' );
  19.     if ( $site_description && ( is_home() || is_front_page() ) )
  20.         $title = "$site_description";
  21.  
  22.     // Add a page number if necessary.
  23.     if ( $paged >= 2 || $page >= 2 )
  24.         $title = "$title $sep " . sprintf( __( 'Page %s', 'twentytwelve' ), max( $paged, $page ) );
  25.  
  26.     // Add the site name before the other stuff.
  27.     $title = get_bloginfo( 'name' ) . ' ' . $sep . ' '  . $title;
  28.  
  29.     return $title;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement