admin管理员组

文章数量:1130349

I have inherited the job of editing my agency's webpage. I didn't create the site, and I am not sure whether the IMW custom theme that is active is a child type theme for 2011, or whether all customizations up to this point have been made to the original theme. Do need to create a child theme for this site, how to do that considering all the customizations that have already been applied.

What do I need to provide to support for answers

I read some of the answer posts but still am unsure. So If I do not see "Child" in the CSS, then it is not a child theme? I was thinking that maybe the IMW Custom theme was a child theme itself based on the 2011 theme, just without the word child being used to designate it as such. IF IT IS NOT A CHILD THEME, then all of the customizations up to this point have been done to the theme itself. How would I go about creating a child theme from this point? I am so confused.

I have inherited the job of editing my agency's webpage. I didn't create the site, and I am not sure whether the IMW custom theme that is active is a child type theme for 2011, or whether all customizations up to this point have been made to the original theme. Do need to create a child theme for this site, how to do that considering all the customizations that have already been applied.

What do I need to provide to support for answers

I read some of the answer posts but still am unsure. So If I do not see "Child" in the CSS, then it is not a child theme? I was thinking that maybe the IMW Custom theme was a child theme itself based on the 2011 theme, just without the word child being used to designate it as such. IF IT IS NOT A CHILD THEME, then all of the customizations up to this point have been done to the theme itself. How would I go about creating a child theme from this point? I am so confused.

Share Improve this question edited May 12, 2014 at 15:05 s_ha_dum 65.6k13 gold badges84 silver badges174 bronze badges asked May 11, 2014 at 14:58 adminadmin 611 silver badge2 bronze badges 2
  • 1 You can disable the child theme and see what happens, typically a child theme style.css has the following tag at the top Template: parent theme name here – Wyck Commented May 11, 2014 at 15:02
  • No. That isn't really what the answers say. Read carefully. For example, you aren't looking for "Child" in the stylesheet; you are looking for "Template:" – s_ha_dum Commented May 12, 2014 at 15:11
Add a comment  | 

3 Answers 3

Reset to default 11
  • Read the stylesheet. A child stylesheet must have Template: somethemename to function as a child theme.
  • Look in Appearance -> Themes. A child theme should have a notice about requiring a parent theme.
  • Use code similar to this (note: debugging only):

    add_action(
      'wp_head',
      function () {
        if (get_template_directory() === get_stylesheet_directory()) {
          echo 'not a child';
        } else {
          echo 'child';
        }
      }
    );
    

Reference:

http://codex.wordpress/Child_Themes

Since WP 3.0 there is a function is_child_theme() that returns a bool value.

If you cannot find any CSS in the Appearance > Customize > Additional CSS section, but the current theme has clearly been modified from another theme, follow the Wordpress guide on Creating a Child Theme from a Modified Existing Theme.

The Wordpress explanation clearly walks through how to use a DIFF tool to identify where changes have been made. Keep in mind that this does assume you can find the original, unmodified theme. There's a link to a "worst case scenario" tutorial, which sounds like what you might be facing.

I have inherited the job of editing my agency's webpage. I didn't create the site, and I am not sure whether the IMW custom theme that is active is a child type theme for 2011, or whether all customizations up to this point have been made to the original theme. Do need to create a child theme for this site, how to do that considering all the customizations that have already been applied.

What do I need to provide to support for answers

I read some of the answer posts but still am unsure. So If I do not see "Child" in the CSS, then it is not a child theme? I was thinking that maybe the IMW Custom theme was a child theme itself based on the 2011 theme, just without the word child being used to designate it as such. IF IT IS NOT A CHILD THEME, then all of the customizations up to this point have been done to the theme itself. How would I go about creating a child theme from this point? I am so confused.

I have inherited the job of editing my agency's webpage. I didn't create the site, and I am not sure whether the IMW custom theme that is active is a child type theme for 2011, or whether all customizations up to this point have been made to the original theme. Do need to create a child theme for this site, how to do that considering all the customizations that have already been applied.

What do I need to provide to support for answers

I read some of the answer posts but still am unsure. So If I do not see "Child" in the CSS, then it is not a child theme? I was thinking that maybe the IMW Custom theme was a child theme itself based on the 2011 theme, just without the word child being used to designate it as such. IF IT IS NOT A CHILD THEME, then all of the customizations up to this point have been done to the theme itself. How would I go about creating a child theme from this point? I am so confused.

Share Improve this question edited May 12, 2014 at 15:05 s_ha_dum 65.6k13 gold badges84 silver badges174 bronze badges asked May 11, 2014 at 14:58 adminadmin 611 silver badge2 bronze badges 2
  • 1 You can disable the child theme and see what happens, typically a child theme style.css has the following tag at the top Template: parent theme name here – Wyck Commented May 11, 2014 at 15:02
  • No. That isn't really what the answers say. Read carefully. For example, you aren't looking for "Child" in the stylesheet; you are looking for "Template:" – s_ha_dum Commented May 12, 2014 at 15:11
Add a comment  | 

3 Answers 3

Reset to default 11
  • Read the stylesheet. A child stylesheet must have Template: somethemename to function as a child theme.
  • Look in Appearance -> Themes. A child theme should have a notice about requiring a parent theme.
  • Use code similar to this (note: debugging only):

    add_action(
      'wp_head',
      function () {
        if (get_template_directory() === get_stylesheet_directory()) {
          echo 'not a child';
        } else {
          echo 'child';
        }
      }
    );
    

Reference:

http://codex.wordpress/Child_Themes

Since WP 3.0 there is a function is_child_theme() that returns a bool value.

If you cannot find any CSS in the Appearance > Customize > Additional CSS section, but the current theme has clearly been modified from another theme, follow the Wordpress guide on Creating a Child Theme from a Modified Existing Theme.

The Wordpress explanation clearly walks through how to use a DIFF tool to identify where changes have been made. Keep in mind that this does assume you can find the original, unmodified theme. There's a link to a "worst case scenario" tutorial, which sounds like what you might be facing.

本文标签: How to know if a child theme is being used