首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >子主题不能在新的index.php上加载我的css

子主题不能在新的index.php上加载我的css
EN

Stack Overflow用户
提问于 2021-01-05 16:50:49
回答 1查看 246关注 0票数 0

我有一些css样式和子主题的问题。我创建了一个子主题,从wordpress的21个主题开始。

css样式:

代码语言:javascript
复制
/*
Theme Name: Twenty Twenty-One Child
Theme URI: https://wordpress.org/themes/twentytwentyone/
Template: twentytwentyone
Author: the WordPress team
Author URI: https://wordpress.org/
Description: Twenty Twenty-One is a blank canvas for your ideas and it makes the block editor your best brush. With new block patterns, which allow you to create a beautiful layout in a matter of seconds, this theme’s soft colors and eye-catching — yet timeless — design will let your work shine. Take it for a spin! See how Twenty Twenty-One elevates your portfolio, business website, or personal blog.
Tags: one-column,accessibility-ready,custom-colors,custom-menu,custom-logo,editor-style,featured-images,footer-widgets,block-patterns,rtl-language-support,sticky-post,threaded-comments,translation-ready
Version: 1.1.1609775076
Updated: 2021-01-04 16:44:36

*/

h2{
    background-color:red;
}

functions.php:

代码语言:javascript
复制
<?php
add_action( 'wp_enqueue_scripts', 'enqueue_parent_styles' );
function enqueue_parent_styles() {
    wp_enqueue_style( 'parent-style', get_stylesheet_directory_uri().'/style.css');
    wp_enqueue_style( 'style', get_stylesheet_directory_uri().'/assets/css/bootstrap.css' );
}

好的,让我们开始主题,好的,我看到h2的bg以红色变化,但是..如果我在我的子主题目录中创建我的文件index.php,我看不到样式!

index.php

代码语言:javascript
复制
<h2>hello!</h2>

在“网络”控制台中没有样式,没有对我的样式表的调用。我不明白!为什么我创建一个index.php wordpress不能加载我的样式?问题出在哪里?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-01-05 17:33:40

看看主题提供的index.php或其他phps可能很有用,看看它们做了什么。

Wordpress确实允许你编写完全“普通”的模板,覆盖所有正常的页眉/页脚。

我怀疑你需要看看get_header()函数,但最好先看看你选择的主题通常做些什么,然后在此基础上进行构建。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65575683

复制
相关文章

相似问题

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