![](/img/trans.png)
[英]Cannot update Wordpress theme and plugins (file permission issues) in linux server
[英]Wordpress Theme issues
所以我目前正在开发一些Wordpress主题,没什么特别的。 改天我遇到了问题。 当我将以下代码添加到header.php时,问题就这样了:
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/reset.css" type="text/css">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css">
一切正常,但是当我进行以下更改时
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/reset.css" type="text/css">
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/css/style.css" type="text/css">
我收到模板丢失的错误。
包含样式表文件的正确方法是使用enqueue_style函数。
转到主题的functions.php文件并搜索: function themename_enqueue_style()
function themename_enqueue_style() {
/* Past the wp_enqueue_style() below in this function */
wp_enqueue_style( 'reset-style', get_template_directory_uri() . '/css/reset.css', false);
}
/* Don't forget Add_action below the function */
add_action( 'wp_enqueue_scripts', 'themename_scripts_styles' );
在标准的WordPress安装中,这两个语句将指向不同的位置。
<?php bloginfo('stylesheet_url'); ?>
将返回“ yoursite.com/wp-content/themes/active_theme/style.css”。
<?php bloginfo('stylesheet_directory'); ?>/css/style.css
将会是“ yoursite.com/wp-content/themes/active_theme/css/style.css”。
您也可以尝试以下方法:
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/reset.css" type="text/css">
<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/style.css" type="text/css">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.