【发布时间】:2015-07-19 12:58:08
【问题描述】:
我正在创建自己的 WordPress 主题并尝试将我的 css 放入 functions.php 中
当我导航到 wp-admin/Themes 时,它说我的模板丢失了,我只能假设它与我的函数有关,但我看不到在哪里。
我的 PHP 文件位于主题根文件夹中,而 css 位于其自己的文件夹中
Functions.php
<?php
function LoadResources () {
wp_enqueue_style( 'style', get_template_directory_uri() . '/css/style.css' );
}
add_action('wp_enqueue_style', 'LoadResources');
Header.php
<!doctype html>
<html>
<head>
<meta charset="<?php bloginfo('charset') ?>">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title><?php the_title() ?></title>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
编辑
【问题讨论】:
-
请发布完整的错误。此外,没有
'wp_enqueue_style'动作挂钩。你应该使用add_action( 'wp_enqueue_scripts', 'LoadResources' ); -
the_title()错误
标签: wordpress wordpress-theming