我有一些css样式和子主题的问题。我创建了一个子主题,从wordpress的21个主题开始。
css样式:
/*
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:
<?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
<h2>hello!</h2>在“网络”控制台中没有样式,没有对我的样式表的调用。我不明白!为什么我创建一个index.php wordpress不能加载我的样式?问题出在哪里?
发布于 2021-01-05 17:33:40
看看主题提供的index.php或其他phps可能很有用,看看它们做了什么。
Wordpress确实允许你编写完全“普通”的模板,覆盖所有正常的页眉/页脚。
我怀疑你需要看看get_header()函数,但最好先看看你选择的主题通常做些什么,然后在此基础上进行构建。
https://stackoverflow.com/questions/65575683
复制相似问题