WP title mod: Fatal error

While using any theme besides Twenty Twelve, install and active the attached zip.

Download Zip

Expected Outcome Expected Outcome

The plugin should activate without any errors.

Activate the theme Twenty Twelve and you will have either a white screen of death or an error 500.

Top ↑

How to fix How to fix

If you haven’t already, turn on debug by editing your wp-config.php file and changing the WP_DEBUG define to true: define('WP_DEBUG', true);

Now you’ll have an error like this:

Fatal error: Cannot redeclare twentytwelve_wp_title() in /Applications/MAMP/htdocs/wordpress/wp-content/themes/twentytwelve/functions.php on line 165

Top ↑

How to Fix How to Fix

This error points the finger at your theme, rather than the plugin you just activated. If you want to revert themes, you will need to edit the database.

  1. Look in the wp-content/themes directory to find the directory name for another installed theme (or just go with twentyeleven, or twentyten as common defaults).
  2. Login to phpMyAdmin for your WordPress database and locate the options table (normally named wp_options).
  3. Look through the options table until you find options for template and stylesheet.
    Screen Shot showing theme name in the database
  4. Edit both options to use the name of the directory of an installed theme.
    Screen Shot showing updated theme name

Of course this doesn’t fix the problem. If you view the plugin source code, you’ll see the following:

// I saw this great function in Twenty Twelve and didn't change the function name!
function twentytwelve_wp_title( $title, $sep ) {
	global $paged, $page;

	...

}
add_filter( 'wp_title', 'twentytwelve_wp_title', 10, 2 );

In this case, this issue is caused by having two functions with the same name. Functions have to have unique names, otherwise a computer just won’t know what to do with them.

The ‘fix’ would be to rename twentytwelve_wp_title to something else. However realistically you don’t need the plugin at all anymore, since you’re using the actual theme Twenty Twelve.