WordPress Twenty Eleven Child Theme Shiv

WordPress’s Twenty Eleven child themes make great use of HTML5, but suffer from one particular flaw. They require you to hack apart functions hijacking your code in unexpected situations. Because of this, I’ve created a Twenty Eleven child theme shiv that removes all the extra junk, so you don’t have to worry about manually cleaning everything.

How it Works

To use the following code shiv, store it in a file called twentyeleven-shiv.php inside your child theme. Most people would tell you to place it in functions.php, but its a bad idea. Shoving too much code in functions.php turns it into an unobtainable mess over time.

Although I told you not to place the Twenty Eleven Child Theme shiv in functions.php, that isn’t quite true. It wont activate until we reference it there (origin point for most custom code in themes). Include the following code snippet at the top of functions.php and you’ll be good to go.

include STYLESHEETPATH . '/include/twentyeleven-shiv.php';

I normally like to credit authors for their code snippets in files I assemble, but there are too many to list. A lot of these code chunks literally came from 2 – 3 sources and were combined for the desired functionality.

What Twenty Eleven Child Theme Shiv Does

Although some of the code here may look unfamiliar, my notes should fill you in on the functionality. If you don’t like anything I’m doing, simply comment it out and the shiv will still work perfectly fine. Since you’re here though, I’ll walk through step by step on how the shiv works.

Remove Read More Jumping

Since Twenty Eleven doesn’t stop your content’s ‘Read More’ links from following a bookmark and jumping down the page, I’ve included a fix. A majority of developers remove this anyway, so it prevents re-writing code.

Removes Sidebar, Menus, and Post Formats

I personally don’t care for the sidebar and menu naming schemes carried into a Twenty Eleven Child Theme. I always end up renaming them, so they’ve been removed. Post formats have also been removed. Since you probably only need a few, you can tell it what particular formats you want right after removing them.