我正在尝试向我正在开发的WordPress主题添加CSS样式,如本教程所示:http://www.wpbeginner.com/wp-tutorials/how-to-properly-add-javascripts-and-styles-in-wordpress/ 但似乎不起作用,我不明白为什么。
这就是head.php 我的个人主题文件:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="<?php bloginfo(\'html_type\'); ?>; charset=<?php bloginfo(\'charset\'); ?>" />
<title><?php bloginfo(\'name\'); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?></title>
<meta name="generator" content="WordPress <?php bloginfo(\'version\'); ?>" /> <!-- leave this for stats -->
<!--
<link rel="stylesheet" href="<?php bloginfo(\'stylesheet_url\'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo(\'name\'); ?> RSS Feed" href="<?php bloginfo(\'rss2_url\'); ?>" />
-->
<link rel="pingback" href="<?php bloginfo(\'pingback_url\'); ?>" />
<!-- <?php bloginfo(\'stylesheet_directory\'); ?>/ -->
<script language="javascript" type="text/javascript" src="<?php bloginfo(\'stylesheet_directory\'); ?>/js.js"></script>
<!--
<script language="javascript" type="text/javascript">
if(f)
{
write_css(\'<?php bloginfo(\'stylesheet_directory\'); ?>\');
}
</script>
-->
<?php wp_head(); ?>
</head>
<body>
<center>
<div id="page">
<div id="header">
<h1><a href="<?php echo get_settings(\'home\'); ?>"><?php bloginfo(\'name\'); ?></a></h1>
<div class="description"><?php bloginfo(\'description\'); ?></div>
</div>
<hr />
在我的functions.php 文件我已输入以下代码:<?php
function wpb_adding_styles() {
wp_register_script(\'my_stylesheet\', plugins_url(\'style.css\', __FILE__));
wp_enqueue_script(\'my_stylesheet\');
}
add_action(\'wp_enqueue_scripts\', \'wpb_adding_styles\');
?>
但是文件style.css 未加载。为什么?我错过了什么?特别是在上一篇教程中,我无法理解的是wpb_adding_styles() 调用,因为在标头中。php文件,它从未被调用。
有人能帮我吗?
Tnx公司
安德烈