首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >get_template_directory_uri()链接到子主题而不是父主题

get_template_directory_uri()链接到子主题而不是父主题
EN

WordPress Development用户
提问于 2016-11-03 15:13:43
回答 1查看 2.4K关注 0票数 0

我已经创建了一个父主题的子主题,它在wp主题选择器上正确显示并激活。

我创建了一个包含以下元信息的子主题的style.css

代码语言:javascript
复制
/*
 Theme Name:   Twenty Sixteen Child
 Theme URI:    http://localhost:888/wordpress-test/twentysixteen-child/
 Description:  My first child theme, based on Twenty Sixteen
 Author:       Juan D. Bolanos
 Author URI:   http://synchronygroup.com
 Template:     Twenty Sixteen
 Version:      1.0.0
 Tags:         black, green, white, light, dark, two-columns, three-columns, left-sidebar, right-sidebar, fixed-layout, responsive-layout, custom-background, custom-header, custom-menu, editor-style, featured-images, flexible-header, full-width-template, microformats, post-formats, rtl-language-support, sticky-post, theme-options, translation-ready, accessibility-ready, responsive-layout, infinite-scroll, post-slider, design, food, journal, magazine, news, photography, portfolio, clean, contemporary, dark, elegant, modern, professional, sophisticated
 Text Domain:  twentysixteen-child
*/

我创建了一个上述主题的function.php文件,并使用wp_enqueue_styles函数作为引用的这里

代码语言:javascript
复制
<?php
function wordpress_main_style() {
        wp_enqueue_style( 'parent-theme', get_template_directory_uri() . '/style.css');
        wp_enqueue_style( 'child-theme', get_stylesheet_uri());
}
add_action( 'wp_enqueue_scripts', 'wordpress_main_style' );
?>

我已经将wp_head()包含在我的header.php中,并调用到了我的index.php中。样式表显示在站点上,如检查器中所示,但“父主题”样式表指向与父目录相关联的子主题目录。

我已经确保文件夹名与在我的子主题中包含'- child‘匹配。我读过这个文档,以确保没有任何错误。

有什么可能会导致目录中的错误方向呢?

EN

回答 1

WordPress Development用户

回答已采纳

发布于 2016-11-03 15:45:31

如果您查看原始文章:

代码语言:javascript
复制
Template:     twentyfourteen

我们看到提到了文件夹twentyfourteen,也就是“二十四号”主题。

而你有:

代码语言:javascript
复制
Template:     Twenty Sixteen

它是主题的人类可读的名称,而不是主题文件夹名。这就是你需要写的:

代码语言:javascript
复制
Template:     twentysixteen
票数 1
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/244964

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档