确保文件的命名和标签正确,位置正确。
<小时>functions.php 位于@mytheme/functions.php
<?php
/**
* Theme Functions
*/
function theme_name_scripts() {
wp_enqueue_style( \'style-name\', get_stylesheet_uri() );
wp_enqueue_style( \'style-name\', get_stylesheet_uri() );
}
add_action( \'wp_enqueue_scripts\', \'theme_name_scripts\' );
<小时>
style.css 位于@
mytheme/style.css/*
Theme Name: Twenty Thirteen
Theme URI: http://wordpress.org/themes/twentythirteen
Author: the WordPress team
Author URI: http://wordpress.org/
Description: The 2013 theme for WordPress takes us back to the blog, featuring a full range of post formats, each displayed beautifully in their own unique way. Design details abound, starting with a vibrant color scheme and matching header images, beautiful typography and icons, and a flexible layout that looks great on any device, big or small.
Version: 1.0
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Tags: black, brown, orange, tan, white, yellow, light, one-column, two-columns, right-sidebar, flexible-width, custom-header, custom-menu, editor-style, featured-images, microformats, post-formats, rtl-language-support, sticky-post, translation-ready
Text Domain: twentythirteen
This theme, like WordPress, is licensed under the GPL.
Use it to make something cool, have fun, and share what you\'ve learned with others.
*/
如果你自己创建这个主题,很可能是拼写错误或者你忘记了什么。
如果要使用标题,请确保模板正在获取标题。php:
<?php get_header(); ?>
在标题或模板中,您需要:
<?php wp_head(); ?>
我猜这是上面的一个,因为您说过添加标记时它会起作用。如果不是,请尝试更改css文件的名称和/或添加更高的优先级。如果您安装了插件,其中一个插件可能对其插件样式表使用相同的“句柄”。
因此,不是:
wp_enqueue_style( \'style-name\', get_stylesheet_uri() );
尝试一些随机的方法,例如:
wp_enqueue_style( \'style189304\', get_stylesheet_uri() );