WordPress - 子主题不会在新索引上加载我的 css.php



我在css样式和子主题方面有一些问题。我创作了一个儿童主题,从wordpress的二十一主题开始。

样式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.hp:

<?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却不能加载我的风格?问题出在哪里?

查看主题提供的index.php或其他php可能很有用,以了解它们的作用。

Wordpress确实允许您编写完全"香草"的模板,覆盖所有正常的页眉/页脚。

我怀疑您需要查看get_header()函数,但最好从您选择的主题的正常功能开始,并在此基础上进行构建。

最新更新