Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我能';t使用WordPress中的函数将css排队_Css_Wordpress - Fatal编程技术网

我能';t使用WordPress中的函数将css排队

我能';t使用WordPress中的函数将css排队,css,wordpress,Css,Wordpress,如果我使用 <link rel = "stylesheet" type = "text/css" href = "<?php echo get_template_directory_uri();?>/style.css"> 您可以按如下方式更正代码: function include_css(){ wp_enqueue_style('main_css',get_template_directory_uri().'/style.css'); } add_acti

如果我使用

<link rel = "stylesheet" type = "text/css" href = "<?php echo get_template_directory_uri();?>/style.css">

您可以按如下方式更正代码:

function include_css(){

    wp_enqueue_style('main_css',get_template_directory_uri().'/style.css');
}
add_action('wp_enqueue_scripts','include_css');

问题是,您试图将css文件排队,而不指定它的完整url和您使用的代码,即

> wp_enqueue_style('main_css',get_stylesheet_uri());
这意味着您正在添加style.css文件,该文件始终位于根目录中,但您仍以main_css命名。首先,请确保您要添加的css,然后有人能够正确回答您的问题,并且您尝试添加的css位于哪个目录中


请参考此链接

请在theme的functions.php中添加此代码

1.we need to register our stylesheet.
2.we should enqueue it.
3.Hook to an action 
4.call the function where you want to enqueue it.

function include_css()
{
    wp_register_style('main_css',get_template_directory_uri().'/style.css');
    wp_enqueue_style('main_css');
}
add_action('wp_enqueue_scripts','include_css');
函数排队_脚本(){ wp_enqueue_style('style',get_stylesheet_directory_uri()。/style.css',array()); }
添加_操作(“wp_排队_脚本”、“排队_脚本”)

要将样式表排队,请在functions.php中使用此选项

1.we need to register our stylesheet.
2.we should enqueue it.
3.Hook to an action 
4.call the function where you want to enqueue it.

function include_css()
{
    wp_register_style('main_css',get_template_directory_uri().'/style.css');
    wp_enqueue_style('main_css');
}
add_action('wp_enqueue_scripts','include_css');
打电话,,

在您要排队的地方。(主要在标题中。)

请添加更多说明