This is a follow-up of our previous post where we reviewed Twenty Eleven – the new default theme for WordPress 3.2. In the previous post I explained the the structure of Twenty Eleven and why it’s so easy for developers to take advantage of the theme to customize it for their own purposes, i.e. creating a child theme based on Twenty Eleven.
Today we’ll have more code, we’ll talk about some neat actions and filters that Twenty Eleven has to offer. We’ll create a new child theme for Twenty Eleven but instead of overriding it’s templates, we’ll use our PHP skills to create a new color scheme for Twenty Eleven — an orange one.

Understanding Color Schemes in Twenty Eleven
You’ve all seen the Theme Options settings that Twenty Eleven ships with, which not only looks good and works well, but is also extensible with plugins, extra code snippets in Twenty Eleven (not recommended) and a child theme (recommended). Here’s what the original Theme Options page looks like.

And here’s what we’re going to make our child theme add to that screen — a new option for the orange color scheme, which will also set the default links color to orange, but of course can be overridden by the end user.

In the previous article I wrote about the Twenty Eleven files structure, and just as a recap, the theme options page is not written in the functions.php directly, but included from within functions.php. The actual content for the theme options page is in /inc/theme-options.php file, so let’s take a closer look at that.
There’s a bunch of stuff there, but we’re interested in the function called twentyeleven_color_schemes, which is around line 110. As you can see, the function returns an associative array of arrays defining the existing color schemes. But before it returns that, it runs it through a filter called twenty_eleven_color_schemes. We’ll hook to that filter and add our new color scheme for the options panel.
Second interesting function is the twentyeleven_enqueue_color_scheme at around line 324. It enqueues the dark.css file if the the color scheme is set to “dark”. There, they’ve just shown us the right way to do it. Apparently we can inject our own stylesheet using the twentyeleven_enqueue_color_scheme action, where we’ll have to compare the current selected color scheme to “orange” and enqueue our stylesheet using wp_enqueue_style.
So that’s the game plan — add a new color scheme to the color schemes array, enqueue the stylesheet if our color is selected. But before diving into that part of the code, let’s create our child theme and make sure it works.
Creating the Child Theme
The basic principles of child themes is that they’re themes of their own, but instead of having their own template files, they use the parent theme’s files with the ability to override some of them. This means that if WordPress has been asked for the index.php template file, it will first search your child theme directory for one, and if it isn’t there it will fall back to the parent theme’s directory and and use the parent’s template.
Note that the functions.php file is different — it never gets overridden by child themes because WordPress will load both functions.php files so you don’t have to copy anything from you parent’s functions.php, that will be executed anyway.
The Child Theme Stylesheet
So as the codex entry suggests, let’s create a new child theme called Twenty Eleven Orange. Start by creating a new directory in your themes folder right next to the twentyeleven directory and call it twentyeleven-orange. Note that both themes have to be installed side-by-side in order for your theme to work, since it will be using the template files from the original Twenty Eleven theme.
Stick in a new style.css file into your directory and add the following contents:
/*
Theme Name: Twenty Eleven Orange
Theme URI: http://theme.fm
Description: Child theme for the Twenty Eleven theme
Author: Konstantin Kovshenin
Author URI: http: //theme.fm
Template: twentyeleven
Version: 1.0
*/
@import url("../twentyeleven/style.css");
The header and the import directive is really all we need for our child theme. This will make sure that WordPress recognizes the new theme, and we’re also telling WordPress to use Twenty Eleven as the parent theme using the “Template:” tag. Now, when the theme is activated WordPress will load our stylesheet and not Twenty Eleven’s, so we’re using the import directive in CSS to grab the original stylesheet from Twenty Eleven.
You might ask where the orange stuff is, right? Well we’ll put that in a separate file called orange.css and load it only when it’s been selected in the theme options. This will make sure that the light and dark color schemes of Twenty Eleven still work as expected.
The Orange Theme Stylesheet
Let’s go ahead and create the orange.css stylesheet too, right next to your style.css file. You don’t have to dig into the contents of the file itself, all it’s doing is creating an orange background for the site and making sure that the background color for the navigation menu is orange when hovered.
body {
background: orange;
}
#access .menu li a {
color: orange;
}
#access .menu ul.children > li:hover > a,
#access .menu ul.sub-menu > li:hover > a,
#access .menu > ul > li:hover > a,
#access .menu > li:hover > a {
color: white;
background: orange;
}
#access .menu ul.children li a,
#access .menu ul.sub-menu li a
{
background: #333;
border-bottom: dotted 1px #555;
color: orange;
}
We’re not creating any rules for the ancor entry for all links, and yes, we want them to be orange. In this case, the body background and the navigation items is enough, since Twenty Eleven has a “default link color” entry for each of the color schemes which the user can then change. We don’t want to hard-code that in our stylesheet, do we? And yes, the background color can be manually changed via the Background options under Appearance too ;)
The Color Scheme Thumbnail
Twenty Eleven uses neat thumbnails when selecting color schemes, so I created a very similar image called orange.png, same size (136 by 122 pixels) and dropped it into my child theme’s directory.

I’ll link to that image when declaring a new color scheme for Twenty Eleven in our next and final step — the functions.php file.
The Functions File
It’s a simple functions.php file lying in your child theme’s directory. This is where we’re going to use the action and filter I spoke about earlier to let Twenty Eleven know about our new color scheme. Make sure you start with an opening PHP tag and then type in the following.
add_filter( 'twentyeleven_color_schemes', 'twentyeleven_color_schemes_orange' );
add_action( 'twentyeleven_enqueue_color_scheme', 'twentyeleven_enqueue_color_scheme_orange' );
function twentyeleven_color_schemes_orange( $color_schemes ) {
$color_schemes['orange'] = array(
'value' => 'orange',
'label' => __( 'Orange', 'twentyeleven' ),
'thumbnail' => get_stylesheet_directory_uri() . '/orange.png',
'default_link_color' => '#FFA500',
);
return $color_schemes;
}
function twentyeleven_enqueue_color_scheme_orange( $color_scheme ) {
if ( 'orange' == $color_scheme )
wp_enqueue_style( 'orange', get_stylesheet_directory_uri() . '/orange.css', array(), null );
}
Let’s quickly run through the code. The first two lines are the ones that add the hooks to Twenty Eleven’s color scheme filter and the enqueue color scheme action. Their definitions are quite simple as well. The twentyeleven_color_schemes_orange function takes the $color_schemes array given by Twenty Eleven. We’re extending that array with our own entry, similar to what Twenty Eleven has for the light and dark schemes, and finally returning the new $color_schemes array.
Note that unlike Twenty Eleven, we’re using the get_stylesheet_directory_uri function instead of get_template_directory_uri. This will make WordPress look for the files in our child theme’s directory and not the original Twenty Eleven. Also note that default_link_color entry set to the orange color. As the name suggests, it’s the default links color throughout the website, and this is the reason why we didn’t have an entry for that in our orange.css stylesheet.
The second function is similar to the Twenty Eleven’s enqueue function that we’ve discussed earlier. The $color_scheme argument contains the value of the selected color scheme. We match that to orange and use wp_enqueue_style to include our orange.css file.
Guess what? You’re done! Go ahead and enable your child theme from the Appearance section in your admin panel. Browse to Theme Options and you’ll see your new color scheme available. Select the color scheme, browse to your homepage and voila, it’s orange! Hopefully…

Conclusion
That wasn’t very difficult, was it? Now think about taking this further with a set of five or more different color schemes for Twenty Eleven. Then go back to the Twenty Eleven source code and look for more actions and filters you can take advantage of. Seriously, the possibilities are endless, and with such a clean approach, it’s easier than ever! Yet another reason to love Twenty Eleven and look forward to Twenty Twelve ;)
That’s it folks! Today you’ve learned how to create your very own child theme based on WordPress’ Twenty Eleven theme with only a couple of actions and filters, a stylesheet and an image. Let us know what you have in mind, comments, questions, anything. And thanks for staying tuned to our RSS feed!



Thanks for this intro to Twenty Eleven child theming. I’ve worked with Genesis child themes only and never tried child theming with any other themes. Wondering how far one can push a child theme with 2011 while still maintaining the responsiveness.
Is there a place we can find a list of 2011 actions?
Hey @nomadone, I don’t think there’s an easy way of listing all of them, but here’s a way of listing all the actions and filters on the current page/request, you might be able to then search out the ones with the twentyeleven prefix. Hope that helps!
Thanks for this, I’m using it on my own site along with a few other adjustments. Any idea how one could add a Google font selector to Twenty eleven theme options in a child theme?
Zeaks, sure Google Web Fonts can easily be added to Twenty Eleven as well. If you’re looking to simply use a font then you should import it in your stylesheet, but if you’d like to give end-users the choice of all 200+ Google fonts, you’ll have to code it differently. Perhaps a good topic for one of our future blog posts, what do you think? :)
Yeah I was referring to adding a dropdown selector or even a text field to the current theme settings in a child theme, which would allow a user to select fonts for entry content and maybe a separate one for title fonts.
I think it’s great how your tutorial adds to the current theme options instead of creating a whole new set of options for a Twenty Eleven child theme. I’d love to see a tutorial for this and anything else you thought of.
Zeaks, we’ve got a Facebook thread dedicated to blog post ideas and suggestions. If you submit your suggestion there we’ll surely consider it for our next round :)
Thanks for your input!
To add more color schemes, is it just a matter of copying the functions, and changing orange to blue for example? Or is there an easier way to add more?
Hi Jae, to add more color schemes you don’t have to copy and paste the whole functions, that would be redundant. It’s much easier to simply add another entry in the array in the color schemes filter and then an extra condition for it in the enqueue action.
Just tried and successfully able to create an orange skin. But If I try to create more than 2 skins, it is showing up the last skin and the default white one for rest of the selections
Can you help me with this
Sure thing! Share your code on Gist and comment back your link, I’ll try to find where you (or I) went wrong ;)
Thanks for your quick response Konstantin !
Created separate .css files for skins in child theme’s folder. And created two sets for orange and green here in functions.php
Ofcourse , I did this in a single child theme folder with two colors-orange.css and green.css ( Did n’t added the .css files in Github. I will do it if you need )
Gist -https://gist.github.com/1109689
Hey there, you can use the existing functions to add a new color scheme, besides in your second function you were checking for “orange” again instead of green. I did a rough edit on your code and here’s what I came up with, assuming you have a green.css and a green.png preview file together with the orange ones. Here’s the fork: gist.github.com/1109725.
Hope that works for you, have a great day!
Oh ! Thanks again for your help
It worked
You’re welcome :)
Could extra layouts be added like this as well?
Hey Zeaks, of course, the filter is called
twentyeleven_layoutsand another one calledtwentyeleven_layout_classes. You can learn more by inspecting the /inc/theme-options.php file, it’s quite easy to follow.Cheers!
Thanks for the info. I tried to get it working, I’m not great with php but can usually figure things out. I can get the new layout to show in theme options, but I couldn’t get it to apply. I think I did the first part right, but I’m lost with the twentyeleven_layout_classes, here is what I have so far http://pastebin.com/thwUHdV6
Zeaks, I gave it a go and here’s how I managed to create an extra layout to the theme options and assign it the
three-columnclass name which you can then use in your stylesheet to move elements around if needed: https://gist.github.com/e8e379d3a26bf923a1baHope this helps you out. Cheers!
Looks like I had alot more wrong with it than I thought . I Appreciate you taking the time to figure that out
No probs Zeaks, let us know how it turns out. We managed to actually create a three-column layout with that approach but didn’t have too much time to figure out the correct CSS to do it, so eventually we broke the responsive design of Twenty Eleven, seems like the second sidebar just isn’t meant to be there ;)
After alot of trial and error I did manage to create a 3 column layout, adding an extra widget area. It was a bit wonkey when resizing the browser but now the sidebars fall into place nicely even at very small browser size.
My theme now has 3 new layouts, sidebar left and right, 2 left and 2 right. Your site really helped me alot with my theme, thanks again.
Very glad to hear that Zeaks, you’re welcome! Share a link once your child theme is up and running in the WordPress.org directory :)
Hey Konstantin Kovshenin !
Thanks for the code for – Three column layout
No problem vbk, glad you found it useful ;)
Sorry for all the questions, I swear the is the only twenty eleven tutorial on the net like this. Is there a way that one of the custom color schemes/layouts can be set as default when the theme is activated?
Hey Zeaks, not a problem, we’re here to help :) There’s a filter you might want to take advantage of that returns default options for Twenty Eleven, here’s how you can use it:
add_filter( 'twentyeleven_default_theme_options', 'my_default_options' ); function my_default_options( $options ) { $options['color_scheme'] = 'orange'; return $options; }Off the top of my head, didn’t test it but it should work. More info in theme-options.php around line 160. Hope this helps, cheers!
Thank you so much! This is a great tutorial. :)
You’re welcome Michelle, thanks for your comment!
Hello guys!
I dont understand where exactly I have to place the following code:
Before I got this post I went to hosting cPanel/public_html/wp-content/theme and made a copy of the Twenty Eleven parent theme and put it a different name to the copy thinking that it was a real child theme. But now because the author here say that I have to put that code somewhere Im not sure if what I did was a child theme or not.
Could some one PLEASE explains that for me please? And if I have to put that code somewhere, where it would be place it exactly??
THANKS in advance. I will really appreciate any help on this!
Hey there, I recommend you read about Child Themes from the WordPress Codex before trying to create your own. The code that you mentioned goes to the child theme’s style.css which is the only file in the child theme, meaning you don’t have to copy all your parent theme files otherwise there’s really no point. Child themes are made to override parts of the parent theme via template files and functions, but not copy them completely.
Let me know if you have any further questions :)
~ K
Thank you Konstantin for your anwer.
BTW, what do you think about that I made a copy of the Twenty eleven theme and put it a new name, I called “Twenty eleven baby”. So now, at the “Manage Theme” area, I have both themes, the default Twenty eleven and the “Twenty eleven baby” as “Available Themes”
My question to you Konstantin is this:
Could we consider that the “Twenty eleven baby” is a child theme that I made or not?
I would like to confirm that please.
Thanks again for your great job :)
Hey again. What you did is a copy of the Twenty Eleven theme therefore the answer to your question is no, that’s not what child themes are all about :)
Thanks Konstantin!
Being myself unable to create a child theme… is there any way to get one already made it?
THANKS again!
Not to advertise my site, but using this tutorial, help from Konstantin and other tutorials on this site, here is my child theme http://zeaks.org/nomnom-twenty-eleven-child-theme/
Hey zeaks thanks, your child theme look very nice. Great job in your part.
Do you know where can I find a step by step newbie friendly tutorial on how to create a child theme. Im mean a tutorial where they teach with detail.
So far I just got tutorials that the author give for granted things that are not really for a newbie like me.
Where can I go for a good and detailed tutorial. The WordPress mentioned above is not detained as I need. PLEASE HELP ME I want and I need to get this done even for my own self-esteem as a blogger.
I will really appreciate any advice.
THANKS in advance!
I really don’t understand, you’re saying the tutorial is too complex for you as a newbie, but seriously, did you even read it? I scanned it from top to bottom and here I am, quoting from the article:
So how on earth did you end up copying Twenty Eleven? Do give it another try and this time try and read more carefully, it’s really easy to follow along, seriously :)
~ K
Hi Konstantin thanks again!
I take what yo say “start by creating a new directory in your themes folder right next to the twentyeleven directory”. I take that and went to the Hostgator support guy and they helped me with the rest of the process.
Now I have my first child theme!!
Im grateful with you because you encouraged me to get this done today and Im very happy with that.
THANKS a lot.
You are hilarious :) Congratulations on your first child theme and a big shout out to the support team at Hostgator, in many support companies you’ll usually hear something like “we provide support on our hosting services but not WordPress” :)
Cheers and thanks for stopping by!
That looks wonderful! Well done Zeaks, although you probably should get rid of those nasty shortcodes ;)
Thanks, and I think you’re right about the shortcodes, maybe I’ll add them to a plugin instead.
Yeah, plugin may be better since it’s more portable but still, the whole shortcodes idea.. Really, how are shortcodes different than HTML? You have tags and you have attributes, you just use a different symbol for the code itself which perhaps makes you feel a little bit “safer”.
But not in the long run, when the plugin author decides to stop developing the shortcodes plugin and 6 months later WordPress deprecates half of the functions he has used :) I’m not talking about you Zeaks, I’m talking about it in general and pretty loud :)
Cheers and hope you get that child theme into the .org repo at some point.
I didn’t think wordpress.org allowed child themes to be submitted? I heard talk of it, do you have a link I could use to submit mine?
Child themes were allowed earlier this year, the only problem is that child themes cannot be installed via the WordPress admin yet but it’s in the roadmap for 3.3. I haven’t submitted child themes myself, but my guess is that the process is identical to submitting regular themes, run it through theme check and use the same upload form on WordPress.org.
Nice, I never knew that, I’ll give it a try, it passes the theme test last time I tried, I might wait until the next version though. Thanks for the info
This question is related to the code you posted in comments for adding layouts. I have several layouts in my theme, and to style them without affecting the default layouts, I need to use separate classes for each.
Alot of the custom layouts share style EX: my cusom layout content is narrow, so I use a comment style just for them. This creates alot of extra CSS just to add something like a 5px margin to an area for those layouts.
In theme options the class is set by using EX:
'value' => 'narrow-content-left-sidebar',Could I add an extra class to this somehow, which I could add to all of my custom layouts? Then when I wanted to add CSS to change a similar area in all those layouts, I could just use something like .my-custom-layouts instead of .two-left, .two-right, .three-column, .narrow-sidebar-right, .narrow-sidebar-left
Zeaks, you’ll be better off adding a class to the body element that would represent your custom layout. Look through the code on how to retrieve the currently selected layout, the sidebar.php file has a good example:
Use that in conjunction with
body_classto add your custom class to the body element. Off the top of my head and untested, somewhere in functions.php:That would add the current layout as the body class. Now inside the code before setting
$classes[]you could also run a check to see if$current_layoutis one of your custom layouts and if it is attach a “one-for-all” class before returning the array:Again, this is off the top of my head but hopefully it’ll give you an idea :) Hope this helps!
I love this site, thanks, this should save me alot of time.
You’re very welcome Zeaks :) and thanks for the kind words!
Thank you for the great post! It is wroten really simple!
But I have some troubles with functions.php: after I activate my own theme, I see following message: “Warning: Cannot modify header information – headers already sent by (output started at …\wp-content\themes\twentyeleven-child\functions.php:1) in …\wp-includes\pluggable.php on line 934″.
After that, my site works correctly (orrange), but I still worry because of this error.
Please tell me, what I’m doing wrong?
Pavel, make sure
WP_DEBUGis enabled in your wp-config.php file and try to get an error message about what’s going wrong. Also if you feel like you can paste your code on Gist and let us take a look :)Konstantin ,
I have a doubt about theme options(Not related to Twenty Eleven, but any general theme) and multisite . Can you please help me if I post here?
Hi VBK, sure thing, paste your code on Gist and send us a link :)
I got a solution with the hook ‘edit_theme_options’. I will definitely ask your help if I got any further issues
Thanks for your kind response !
No probs, glad you solved it! :)
great tutorial ;)
i created an ajax twentyeleven child theme.
https://github.com/chrismccoy/twentyeleven-ajax
Chris, nice! Well done :)
Hi there,
thanks for the informative post and being active in your comments section.
I was having trouble with this and was following the codex and these directions and could not get the child theme to appear on appearance>themes.
So I just did some detective work and found that an index.php file must be in the child theme directory for the theme to appear. the file can be blank, but must be present. what gives? and how will this affect me using the child theme?
I have done some customizing of my theme and only recently learned about child themes. I want to implement this functionality as I’d been wondering how I would ever update my theme…
BTW, I’m on hostgator and I love their customer support. Until I read the above story, I didn’t realize how *helpful* they are. :)
Wood, you’re welcome. As far as my experience with child themes goes, a style.css file is enough for the theme to appear in Appearance but you have to make sure you have the right parent template directive in your style.css file. Feel free to post the contents of your style.css file to Gist or something, we’ll take a look :) Thanks for your comment!
You don’t say it like you do with style.css and orange.css, but do I “create” a functions.php file in the same directory as those?
I finally figured out what I was doing wrong.
I DID create a functions.php file. That wasn’t my idiotic problem as to why it wasn’t working for me. I needed to go to Appearance > Themes and select the child theme. Duh!
I had already created child themes on 2 of my other websites about a month ago, but I’d forgotten about that 1 crucial step. I opened one of those sites up to compare and that’s when I found my mistake.
Thanks so much for this wonderful tutorial! If only I had all my brain cells firing correctly, I could have saved myself a lot of grief and an hour of my precious time.
Now to create more color schemes!
Glad you sorted it out :)
Been trying to figure out child themes for days. I don’t know what I’m doing wrong. I create my child theme and it breaks my website.
Here is a screencap of my child theme’s style.css: http://screencast.com/t/FeYzbeDEHw
But whenever I try to activate my child theme all of the formatting gets removed completely: http://screencast.com/t/LHxd9DrldDe
I can’t figure it out. I’ve looked through every tutorial I can find on the net, posted on the WP.org forums, don’t know what I’m doing wrong ;-(
Seems like you’re lacking a slash in your
@importrule in the stylesheet :)Konstantin, thank you for your help. I added the slash so it now looks like this: @import url: (“../twentyeleven/style.css”);
But it’s still not working. The broken site is here: http://www.wordpressarchitect.com/
It’s ironic, because I was trying to create a tutorial on setting up a child theme, so of course it breaks.
The import line in your child theme style.css is wrong, remove the : it should just be @import url(“../twentyeleven/style.css”);
That worked… haha, thank you!
Correct :) Thanks Zeaks!
hi, well my question is not about some color schemes, anyway maybe you have any solution…
is there a way to keep the sidebar and the other content of the twentyeleven theme at the original place when resizing the browserwindow? well everything is moving and the sidebar “disappears” (but it just moved down to the bottom of course). i think that’s very annoying. it should be the same behaviour like your page. everything stays where it should be.
thanks in advance
i finally got it!
i set the width in the #main div to a particular number and suddenly i got my solution. puh!
It took you 13 minutes to figure it out after you’ve asked your question. Good job ;) However, keep in mind that the Twenty Eleven theme is responsive, meaning it will adapt it’s layout to the browser size, making it look good on all screen sizes across different devices, so by setting the main width explicitly you’re loosing that. Thanks for your comment :)
well, yes it were just 13 minutes from reply to reply, but a little more investigation all in all.
do you have any ohter suggestions than define the #main width? i recognized your theme hold the same space to the left or right side when resizing the browser…
mine doesn’t…
thanks!
Our theme is not responsive so it has a static width in pixels unlike Twenty Eleven. If you take a closer look at the stylesheet you’ll see that most of the objects are fluid, i.e. dimensions are specified in em’s and percentages. The real magic though happens in the media queries. Look at around line 2237 in Twenty Eleven’s style.css file, you can override those parts in your child theme’s stylesheet as well if you need to.
one of the best tuts that is simple, short and to the point it helped me to get started with child themes :-)
Thank you,
Karim.
Karim, thanks, glad you enjoyed the post :)
I want to change the dimensions of the header image in twenty eleven – maybe to 204 x 204 instead of 1000 x 288. How do I do this?
(I’m new to customization)
Thanks.
Gary, you can use a filter in your child theme or plugin and hook to
twentyeleven_header_image_widthandtwentyeleven_header_image_height. More about filters. Good luck!Hi,
I’m new to wordpress and trying to create a child theme.
I manage to create a child theme for css, and php page coming from the root directory of the parent theme.
- themes - parent_theme - include - child_themeMy concern now is how can i create a child_theme for php page coming from include folder of the parent_theme. Please help :)
Many Thanks.
June, there’s no easy way to override non-standard WordPress templates (the one coming from the include directory) but you should check on how the file is being called from within the parent theme template files. Perhaps there’s a filter or action you can hook in to or overwrite the function in your child theme. Keep in mind that your functions.php gets loaded before the parent theme’s functions, so you have an advantage ;) Good luck!
You should try this. put this one in theme-functions.php
if ( file_exists(STYLESHEETPATH . '/include/theme-header.php') ) include_once(STYLESHEETPATH . '/include/theme-header.php'); else include_once(TEMPLATEPATH . '/include/theme-header.php');Replace theme-header.php to the path and file of your child.
I have created a child theme but after i had uploaded some custom header images. The child theme seems to have inherited everything but these images. I have read that WP treats uploaded headers individually to the theme and that i needed to re-upload the images. Is there a way to inherit the existing images?
Fred, it’s quite difficult with images and other files since they don’t have the same override mechanism as theme templates do, and moreover, they’re out of your theme’s league because they’re served to the browser directly from your web server (apache, nginx) so you’ll have to figure out how to link to different images instead of overriding the ones that you have. You can share your code on Gist and I’ll see if I can help. Thanks for your comment!
This might be useful to you. I use it on my own child themes. It will remove the Twenty Eleven headers and scan the images folder of your child theme for new images and automatically display them in the header section as default headers.
http://pastebin.com/b01iCT33
Quite an elegant approach Zeaks, thanks for sharing that! My only concern is performance though. I think that the script will talk to the filesystem on each and every request, which might turn out very expensive.
Of course any page caching plugin will hide the bottleneck, but nevertheless you should at least wrap it up in a transient :) The rest is cool!
I’m a newbie, I had spent 5 hours to follow your instruction to make my child theme. But I’ve stuck after I managed to created style.css fild. Would you please tell me how to “create the orange.css stylesheet too, right next to your style.css file. ” and “a very similar image called orange.png,”? Also, I can’t find any function.php or .php files in my child theme(all it has is just style.css). But you said “It’s a simple functions.php file lying in your child theme’s directory.” How can I find it? Would you please show me what is the opening php tag and closing tag? It’s just terrible difficult for me. I’ll appreciate if you can help me out. Thank you.
Joanna, the child theme’s functions.php file is the one you have to create, just like you did with the stylesheet. Same with the orange.css file. Paste your code somewhere on Gist and I’ll try and tell you where you (or I) went wrong :)
I had copy all my php files from root direction. And I went to appearance>editor. It’s pop up as this:
Fatal error: Cannot redeclare twentyeleven_excerpt_length() (previously declared in /home/jojo1668/public_html/profitsourceblog.com/wp-content/themes/twentyeleven-child/functions.php:318) in /home/jojo1668/public_html/profitsourceblog.com/wp-content/themes/twentyeleven/functions.php on line 320
I had to take it away from my /twentyeleven-child file. I’m totally stuck. What should I do in order to keep going?
You shouldn’t copy any of the files Joanna, only override, and functions.php is a special case. Both the child theme’s and the parent theme’s functions.php files will be included when the child theme is activated. Don’t copy any of the template files, that’s not the point of child themes :) Thanks for your comment and good luck!
Wow, it’s simple. Very nice post.
I want to re-size width of themes.
How to do that?
I should do this to adjust adsense (width 715 pixel).
Adcord, it would be quite problematic with Twenty Eleven. You can resize any element you like using your child theme’s stylesheet, but do keep in mind that Twenty Eleven is responsive, meaning it will adjust it’s layout based on the browser width with media queries, so providing pixel sizes might break that aspect :) Good luck!
Thanks for the answer.
It’s gonna be my hardest day :D
Thanks Konstantin, its work for My Blog.
You’re welcome Cerita, thanks for your comment!
I am brand new to WordPress. I am starting my own business and want to create my own website using WordPress. Am interested in using child themes. I followed your instructions for making the orange theme. When you stated “Make sure you start with an opening PHP tag,” did you mean I need this as the first line in my file — need to go anywhere? I installed the orange theme and my site looks correct. When I go to Appearance – Themes – Theme Options, the orange option is there, but there is no visual like the first two options. Just a red x in a box. What am I doing wrong?
I see I’m missing info on my post. The opening php tag “” need to go anywhere?
Alright I’ll spell it!! Is this the opening php tag I need as the first line? less than symbol, question mark, lower case p, lower case h, lower case p
Do I need to place question mark, greater than symbol anywhere? Thanks.
hey there and thank you for a really helpfull guide!
altough it’s very simple, i cant really get it to work. I do not get anything else then a grey background, and spontaniously i can say that the only step i seem to be a bit confused about is the “add a php opening tag”.
isn’t this simply a <?php by itself on the first row?
my work can be looked upon at http://www.appme.nu , i appreciate any help!
Thank you Konstantin Kovshenin for your wonderful tutorial. It’s one of the most useful that I have lately. It’s well organized and explained to the point. Using your tutorial it was a breeze to create a child theme and change it’s color scheme. Thank you very much for your time and I really do appreciate your help.
I will be coming back to your website (theme.fm) for more WordPress knowledge.
Thanks Again.
Hi Konstantin, thanks again. I just have a question regarding theme design switching like 2011-theme, say you can switch two-sidebars and content middle or one-sidebar-left-and content or right-sidebar or any combination. How do you do it? Thanks.
I am building a new homepage in WP but it is new to me. I have already made changes to style.css before making a child theme. This looks like a mistake – I’d welcome your guidance!
In order that a WP or Theme Update does not delete my settings, are the correct steps now:
set style.css back to its original form
make a child theme
rewrite the changes into the child theme
or, can I somehow save the changed stylesheet as/in a child theme?
Or should I have cup of tea and do something else?
By the way, my website address in your reply form links to my existing homepage, not the emerging new one.
James
Your lessons are simple but it was really amazing for me. Thank very much
Can you help me? How can I put the sidebar on the single post? Please I’m really need to know
Thanks :)
Hi there,
Thanks for this nice, easy explanation.
I was wondering if anyone knows how to handle changes to the customer header and custom menus. In other words, what files do I need to use in the child theme to ensure that these are not affected when upgrading/changing the parent.
Thanks,
Kim
For me, activating this new sub-theme deactivated my dynamic menus. Luckily for me, I just had to re-activate them.
Hey Konstantin,
Still struggling with the basics, after creating new folder for the child theme and the style.css I get the same message in WordPress panel saying:
“The following themes are installed but incomplete. Themes must have a stylesheet and a template…The parent theme is missing”
tried going threw it step by step many times and can’t figure out what i missed?!
could it be that the theme I want to work with won’t support child themes?
or maybe WordPress 3.3…?
Thanks,
got it! tried something right this time :)
Thanks Konstantin,
I’ve been heavily studying WordPress for about a year now and found this article to be very helpful in one of my current projects. I am also compiling a Book and a class on teaching people how to develop for the web. I will be referencing you in my materials.
Fantastic Tutorial!
When I finally have a finished project I will post a link here for your viewing pleasure. Again thanks for sharing these tips!
-Jeremy
VP Development at Pro River Technology
Pingback: CP theme is nod for the ..
Great tutorial – I haven’t been able to find anything else as good.
I’m trying to do something that I thought was really simple – to change the font size for headings and paragraph text… I’ve tried putting code into my child theme for font-size, but it doesn’t seem to make any difference.
Any tips would be really helpful!
Hi, Konstantin – I have read ytour article and followed the comments: may I say you have the patience of a saint!
My issue … total newbie, have created the folder and it now includes:
functions.php (copied and pasted from your tut)
orange.css (ditto)
styles.css (with your header and link copied and pasted)
orange.png (well, why not?)
When I select the theme however, the contents of functions.php is written above the header area as unstyled text. If I delete the php file from my orange folder, the mess-up disappears, but of course the styles are unaltered.
Could you please tell me what blindingly obvious thing I have missed?
Much appreciated!
I got what I wanted. Now I am able to add a thumbnail for my child theme. You just have to save the required 300 *225 image to be shown above your child theme as screenshot.png in the root theme folder (the desired child theme folder). You will be able to see the preview .
Thanks
I created a child theme for a new site I am developing, but I’m not sure how I properly include the Google Analytics code. Any suggestions?
How can I remove the default header images?
Hi,
I am working with twenty eleven. I have created my child theme and everything works great. I understand how to add a new color scheme and add new layouts. But what I was not able to do is add a new theme option such as a header logo. It seems there is no way to hook to it.
How would you suggest to add a new theme option from my child theme without changing directly the 2011 theme-options.php page?
Thanks for all your help,
Luc
Pingback: Introduction to WordPress Homework – Class 12 – Video, Audio, and Podcasts | Learning from Lorelle
Pingback: post abc | Ians Test Site
I have been trying to find a way to expand this very good theme, and I stumbled on your instructions.
Thank you for nice and clear directions especially for someone who is still learning.
A couple of questions.
If I want to adjust the header size, I assume I can add a new header.php file in my child theme?
Secondly, is there a simple way of having a vertical menu using a child theme for twentyeleven? I want to see what it looks like, as I do prefer a vertical menu on the left side not the right!
Thanks again.
Kev
This is exactly the thing I needed as twenty eleven was lacking in the color department. I also made the fonts bold to stand out more. Thanks
Pingback: Wordpress Twenty eleven theme Masters Class | Everything Hosting, Domains, Hosting, Reviews and more
Pingback: Walking Through Tutorials | O'Neale dot Net