Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Child theme from twentyeleven: content does not show up WordPress

  • SOLVED

Hi, I'have created a new theme changing many files of twentyeleven, i know is not the correct way to build a new theme so now I want to create a child theme from twentyeleven, so child theme will become new theme and i can restore orginal files in the twentyeleven (to avoid problem with next wp upgrade).
Wp version: 3.4.2

What i did:

1) create another directory with new theme name (following codex instructions)
2) For now, for testing purpose, I put in it: style.css, 404.php, functions.php and other files (you'll see listed below)

In the stylesheet header i've written this code:

/*
Theme Name: Progetto Benessere Completo
Theme URI:
Author: Maryhellen Segatta
Author URI: http://www.maryhellen.it
Description: Child theme for the Twenty Eleven theme
Template: twentyeleven
Version: 0.1.0
*/


and the code in functions.php is:

<?php
require_once( get_stylesheet_directory(). '/index.php' );
require_once( get_stylesheet_directory(). '/sidebar.php' );
require_once( get_stylesheet_directory(). '/header.php' );
require_once( get_stylesheet_directory(). '/footer.php' );
require_once( get_stylesheet_directory(). '/content.php' );
require_once( get_stylesheet_directory(). '/content-single.php' );
require_once( get_stylesheet_directory(). '/content-page.php' );
require_once( get_stylesheet_directory(). '/single.php' );
require_once( get_stylesheet_directory(). '/archive.php' );
require_once( get_stylesheet_directory(). '/404.php' );
require_once( get_stylesheet_directory(). '/search.php' );
require_once( get_stylesheet_directory(). '/searchform.php' );
require_once( get_stylesheet_directory(). '/functions.php' );
require_once( get_stylesheet_directory(). '/images/' );
require_once( get_stylesheet_directory(). '/anythingslider.css' );
require_once( get_stylesheet_directory(). '/js/' );
?>


In preview and when activate this child theme i get page as in the screenshot instead of this:

http://www.progettobenesserecompleto.it/

Simply there is not content!

What i missed?

Thanks fo your help

Answers (3)

2013-03-09

Naveen Chand answers:

Empty your browser's cache. If you are using Chrome, press Ctrl+Shift+Del, check the Empty the cache option and click on Clear Browsing Data.


maryhellen comments:

Done, but nothing changes


Naveen Chand comments:

@maryhellen, Well, I thought you have activated the child theme already. I am sure Navjot and Arnav would have also thought the same way. Anyways, I would suggest you to remove the code in your functions.php You do not need that code. The files will automatically be given preference if you have saved them in child directory. Remove that code and activate. You will get to see the content in your site after activation.


maryhellen comments:

So, i have to delete functions.php?


Naveen Chand comments:

You have to delete the code that you have written in your functions.php (requrire_once lines). You don't have to delete functions.php file if it contains other code. Child theme works this way.. If you have a functions.php in your child directory, then they will be given priority. If you dont have any file in your child directory, the parent files will be given priority. You dont have to tell this to wordpress using require_once functions. Its designed that way. The one and only one important, mandatory file in your child directory is style.css. In your style.css file that you created in your child directory, add this line after */

@import url("../twentyeleven/style.css");

And after that line add all the code you would have written on your own in the main theme. This is where you can customize styles. If you have no customizations, then simply use that line. Infact, as of now that line will be sufficient. but later on, you may want to move your old css file here (placed after this line).


maryhellen comments:

Ok now i see all the content but the right sidebar content (inserted with a text editor widget)

About customize style, because my style.css is completely different, i'd prefer to upload a totally new stylesheet than to import and overwrite style declarations.

Is this correct (it works...)?

I got two questions about two issues after child theme activation:

1) Why i get background color in light gray instead of white (as written in my style sheet)?

2) Is it normal that all the content in the sidebar has been substitute with default sidebar?
Maybe this happens because i inserted content in right sidebar with a widget editor?
Therefore new child theme does not keep content inserted in the widget (plugin used: Black Studio TinyMCE Widget)?
Strange thing is that a block of test in a widget in the footer is still there...
Is it normal?


maryhellen comments:

For the child theme unwanted background color i found that wordpress add a style declaration with background color just before closing html head tag.

Is there a way to stopping wordpress to add automatically this style declaration block and force using background
color in my stylesheet as normally happens in parent theme?

Thanks


Naveen Chand comments:

<blockquote>About customize style, because my style.css is completely different, i'd prefer to upload a totally new stylesheet than to import and overwrite style declarations.

Is this correct (it works...)?
</blockquote>

Yes, you are right. you can have a new stylesheet altogether. In that case you can remove the @import line and put all your new stylesheet in there. It should work.

<blockquote>For the child theme unwanted background color i found that wordpress add a style declaration with background color just before closing html head tag.</blockquote>

I am not sure about what you say. I don't see any style for body being defined just before closing html head tag. But if you think that is what is hindering, you can copy the header.php file in your child directory (I assume you have done that already). Open thta header.php file and edit that style. You can remove that style so that wordpress picks the style you mentioned in your style.

<blockquote>2) Is it normal that all the content in the sidebar has been substitute with default sidebar?
</blockquote>

Usually wordpress tries to put back the widgets as they are as long as the child theme supports it. In the rare event of widgets not appearing, try putting them back in the sidebar. It should work.


maryhellen comments:

About backgroubd color block style declaration in the head tag, you can't see it because it is created only in the child theme.

Strange thing is that header.php file of this child theme is the same of parent theme, but only in the child theme
the code below is created:

<style type="text/css" id="custom-background-css">
body.custom-background { background-color: #f1f1f1; }
</style></head


I do not like to have useless code in my website, have you got any idea to do not allow wordpree to
create this code for child theme background color?

Thanks


Naveen Chand comments:

see this link to know why it is generating that css... [[LINK href="http://codex.wordpress.org/Custom_Backgrounds"]]http://codex.wordpress.org/Custom_Backgrounds[[/LINK]]

you can go to appearance … background option in your dashboard and change the color.


maryhellen comments:

Thanks


maryhellen comments:

The only thing i do not understand is why for parent theme this style block is not added.


maryhellen comments:

Is there a way to avoid that wordpress add this style block automatically in the child theme web page? Why in the parent theme this styke block is not added? Thanks.


Naveen Chand comments:

Put this code in functions.php of the child theme or parent theme - in whichever theme you want to block wordpress from generating that style in the head part of the page. If you don't have functions.php in your child theme, simply create a new file and name it as functions.php and add this code there.


/* Remove theme support for Background */
function remove_custom_theme_support(){
remove_theme_support('custom-background');
}
add_action( 'after_setup_theme', 'remove_custom_theme_support', 11 );


maryhellen comments:

It works! Thanks


Naveen Chand comments:

You're welcome.

2013-03-09

Navjot Singh answers:

But I can see the content on your site.


maryhellen comments:

You are seing twntyeleven changed theme, child theme is not yet activated but i can see result in the preview

2013-03-09

Arnav Joy answers:

why have you written these lines


<?php

require_once( get_stylesheet_directory(). '/index.php' );

require_once( get_stylesheet_directory(). '/sidebar.php' );

require_once( get_stylesheet_directory(). '/header.php' );

require_once( get_stylesheet_directory(). '/footer.php' );

require_once( get_stylesheet_directory(). '/content.php' );

require_once( get_stylesheet_directory(). '/content-single.php' );

require_once( get_stylesheet_directory(). '/content-page.php' );

require_once( get_stylesheet_directory(). '/single.php' );

require_once( get_stylesheet_directory(). '/archive.php' );

require_once( get_stylesheet_directory(). '/404.php' );

require_once( get_stylesheet_directory(). '/search.php' );

require_once( get_stylesheet_directory(). '/searchform.php' );

require_once( get_stylesheet_directory(). '/functions.php' );

require_once( get_stylesheet_directory(). '/images/' );

require_once( get_stylesheet_directory(). '/anythingslider.css' );

require_once( get_stylesheet_directory(). '/js/' );



if you want to have any standard file in child theme then you can create these files in child theme itself .


maryhellen comments:

I have written these lines in the functions.php child theme because i have changed code in files listed.
And obviousely i have uploaded these files in child theme directory


maryhellen comments:

What i'm trying to do is following codex instructions and wp questions advices gave me to a previous question.

I have changed almost all twentyeleven template files code (sidebar.php, content.php etc, you can see above)
and, as suggested, i have included these files in the child theme functions.php.

What i missed, why content does not show up (i have checked up code: there is not content, only blank divs)?

Maybe i have to rename these files?