You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress子主题安装报错:父子主题均被识别为子主题

Fix: Parent & Child Themes Both Showing as Child Themes in WordPress

It sounds like the issue is rooted in incorrect header declarations in either your parent or child theme's style.css file. Here's how to troubleshoot and fix it:

1. Check the Parent Theme's style.css (Critical!)

Parent themes should never include a Template: line in their header—this is exclusive to child themes. If your parent theme has this line, WordPress will mistakenly flag it as a child theme.

  • Navigate to /wp-content/themes/consulting/ (your parent theme folder) and open style.css.
  • Look for any line starting with Template:. If you find it, delete it immediately.
  • A correct parent theme header should look like this:
    /*
    Theme Name: consulting
    Theme URI: http://example.com/consulting/
    Description: A professional consulting theme
    Author: John Doe
    Author URI: http://example.com
    Version: 1.0
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    Text Domain: consulting
    */
    

2. Validate the Child Theme's style.css Header

Your child theme's header must have a Template: line that exactly matches the parent theme's folder name (this is case-sensitive, especially on Linux servers).

  • Open your child theme's style.css file.
  • Ensure the Template: value matches the parent's folder name (e.g., if parent is in /consulting/, use Template: consulting).
  • Example of a correct child theme header:
    /*
    Theme Name: consulting Child
    Theme URI: http://example.com/consulting-child/
    Description: Custom child theme for consulting
    Author: John Doe
    Author URI: http://example.com
    Template: consulting
    Version: 1.0.0
    Text Domain: consulting-child
    */
    
  • Common mistakes here: Typos in the folder name, using the theme's display name instead of the folder name, or incorrect capitalization (e.g., Consulting instead of consulting).

3. Verify Folder Names

Double-check that your parent theme's folder name is exactly what you specified in the child's Template line. For example, if the parent folder is named consulting-v2, your child's Template line must be Template: consulting-v2.

4. Apply Changes and Test

  • Save all edits to both style.css files.
  • Go to your WordPress Dashboard > Appearance > Themes. You should now see the parent theme as a standalone theme, and the child theme marked as a child of "consulting".
  • If the issue persists, clear any caching plugins you're using and refresh the themes page.

This should resolve the problem where both themes are being recognized as child themes. The most common culprit is accidentally adding a Template: line to the parent theme when copying code from the Codex.

内容的提问来源于stack exchange,提问作者user9340719

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:38:26