How to Change DOCTYPE in the Thesis 1.8 WordPress Theme

by Peter

Thesis 1.8 uses DOCTYPE 1.0 Strict. This is fine if that’s the right DOCTYPE for the content of your WordPress blog. Otherwise you may want to change it. If you do, there are mainly two options available to you:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE HTML>

The first is 1.0 Transitional, and the second and much shorter DOCTYPE declaration is HTML 5. You can read a little about the advantages and disadvantages of each in my previous post about how to change DOCTYPE in WordPress, which also has links to more informative articles.

Changing DOCTYPE in the Thesis theme is a little different from changing it in other themes but just as easy. There are two ways to do it.

Using custom_functions

Go to the file “/wp-content/themes/thesis1_8/custom/custom_functions.php”. Make a backup of the file. First, for 1.0 Transitional, copy and paste the following into the file and replace the file.

/* !Custom Doctype */
function custom_doctype() {
    return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
}
add_filter('thesis_doctype','custom_doctype'); 

To change the DOCTYPE to HTML 5, copy, paste and then replace the file after adding the following:

/* !Custom Doctype */
function custom_doctype() {
    return '<!DOCTYPE html>';
}
add_filter('thesis_doctype','custom_doctype'); 

And that’s it. I’ve tested both, and they both change the DOCTYPE the way they should.

Changing “frameworks.php”

The second, and “cleaner” way to change the DOCTYPE of a Thesis 1.8 WordPress blog, is to edit one of the “core” files of the Thesis framework, the file “frameworks.php”. This is the file that actually assigns DOCTYPE 1.0 Strict in the first place, so changing the DOCTYPE declaration at this point is in a sense more correct, and also cleaner (as you will see), especially in the case of HTML 5. I used this method to change to 1.0 Transitional for this blog.

First, you need to open the file “/wp-content/themes/thesis1_8/lib/html/frameworks.php” (it’s smart to make a backup before you edit it). On the very top of the file you see:

	echo apply_filters('thesis_doctype', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">') . "\n";
?>
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>

1.0 Transitional

For 1.0 Transitional all you need to do is to copy and paste the Transitional DOCTYPE declaration given at the beginning of this post into the first line above (between the apostrophes), like so:

	echo apply_filters('thesis_doctype', '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">') . "\n"; 

Then save the file, clear the cache if you use one, and check it.

HTML 5

The correct way to change into DOCTYPE HTML (HTML 5) is to change both the first and the second line in “frameworks.php”. The reason is that the <html>-tag in the HTML 5 DOCTYPE is different from the ones for 1.0 Strict and 1.0 Transitional. It is simply an empty tag or a tag that defines language, that is either simply <html> or something like <html lang=”en”>.

So now you replace both the lines with the following:

	echo apply_filters('thesis_doctype', '<!DOCTYPE html>') . "\n";
?>
<html <?php language_attributes(); ?>>

Again, save the file, (clear the cache) and check the result.

That’s it. Good luck!

PS: Full disclosure: May I add that I am a great fan of the Thesis theme, and use it on several sites. I am also an affiliate of DIYThemes because I use it and like it. It’s a theme I recommend – fast, easy to customize, and with good support:

Thesis Theme for WordPress:  Options Galore and a Helpful Support Community

Related Posts:

Leave a Comment