我有个奇怪的问题。尝试将CSS文件排入现有functions.php
但似乎什么都没用。这是函数文件的相关部分,由其他人根据2616主题制作:
function twentysixteen_scripts() {
// Add custom fonts, used in the main stylesheet.
wp_enqueue_style( \'twentysixteen-fonts\', twentysixteen_fonts_url(), array(), null );
// Add Genericons, used in the main stylesheet.
wp_enqueue_style( \'genericons\', get_template_directory_uri() . \'/genericons/genericons.css\', array(), \'3.4.1\' );
wp_enqueue_style( \'bootstrap\', get_template_directory_uri() . \'/css/bootstrap.css\', array(), \'3.4.1\' );
wp_enqueue_style( \'theme-owl\', get_template_directory_uri() . \'/css/owl.carousel.css\', array(), \'3.4.1\' );
wp_enqueue_style( \'theme-owl-min\', get_template_directory_uri() . \'/css/owl.theme.css\', array(), \'3.4.1\' );
// Theme stylesheet.
wp_enqueue_style( \'twentysixteen-style\', get_stylesheet_uri() );
if (! is_front_page() || is_single())
{wp_enqueue_style( \'blog-styles\', get_template_directory_uri() . \'full-style.css\', array( \'twentysixteen-style\' ), \'20170410\' );}
// Load the Internet Explorer specific stylesheet.
wp_enqueue_style( \'twentysixteen-ie\', get_template_directory_uri() . \'/css/ie.css\', array( \'twentysixteen-style\' ), \'20150930\' );
/* 09.02.2017 */
wp_enqueue_style( \'jquery-ui\', get_template_directory_uri() . \'/css/jquery-ui.css\', array( \'twentysixteen-style\' ), \'20150930\' );
/* 09.02.2017 */
wp_style_add_data( \'twentysixteen-ie\', \'conditional\', \'lt IE 10\' );
// Load the Internet Explorer 8 specific stylesheet.
wp_enqueue_style( \'twentysixteen-ie8\', get_template_directory_uri() . \'/css/ie8.css\', array( \'twentysixteen-style\' ), \'20151230\' );
wp_style_add_data( \'twentysixteen-ie8\', \'conditional\', \'lt IE 9\' );
// Load the Internet Explorer 7 specific stylesheet.
wp_enqueue_style( \'twentysixteen-ie7\', get_template_directory_uri() . \'/css/ie7.css\', array( \'twentysixteen-style\' ), \'20150930\' );
wp_style_add_data( \'twentysixteen-ie7\', \'conditional\', \'lt IE 8\' );
// Load the html5 shiv.
wp_enqueue_script( \'twentysixteen-html5\', get_template_directory_uri() . \'/js/html5.js\', array(), \'3.7.3\' );
wp_script_add_data( \'twentysixteen-html5\', \'conditional\', \'lt IE 9\' );
wp_enqueue_script( \'twentysixteen-skip-link-focus-fix\', get_template_directory_uri() . \'/js/skip-link-focus-fix.js\', array(), \'20151112\', true );
/* 09.02.2017 start */
wp_enqueue_script( \'jquery-ui\', get_template_directory_uri() . \'/js/jquery-ui.js\', array(), \'20151112\', true );
//wp_enqueue_script( \'taskCompRegress\', get_template_directory_uri() . \'/js/taskCompRegress.js\', array(), \'20151112\', true );
if(is_single(556) || is_single(274)){
wp_enqueue_script( \'UXSalary2014\', get_template_directory_uri() . \'/js/UXSalary2014.js\', array(), \'20151112\', true );
}
if(is_single(6440)){
wp_enqueue_script( \'UXSalary2016\', get_template_directory_uri() . \'/js/UXSalary2016.js\', array(), \'20170314\', true );
}
if(is_single(3656)){
wp_enqueue_script( \'UXSalary.js\', get_template_directory_uri() . \'/js/UXSalary.js\', array(), \'20110823\', true );
}
if(is_single(204)){
wp_enqueue_script( \'taskCompRegress.js\', get_template_directory_uri() . \'/js/taskCompRegress.js\', array(), \'20110321\', true );
}
if(is_single(274)){
//wp_enqueue_script( \'UXSalary\', get_template_directory_uri() . \'/js/UXSalary.js\', array(), \'20151112\', true );
wp_enqueue_script( \'npsSUSMeanRegress\', get_template_directory_uri() . \'/js/npsSUSMeanRegress.js\', array(), \'20151112\', true );
}
if(is_single(458)){
wp_enqueue_script( \'UXQuiz\', get_template_directory_uri() . \'/js/UXQuiz.js\', array(), \'20131112\', true );
}
//wp_enqueue_script( \'UXQuiz\', get_template_directory_uri() . \'/js/UXQuiz.js\', array(), \'20151112\', true );
if(is_single(3695)){
wp_enqueue_script( \'bs\', get_template_directory_uri() . \'/js/bs.js\', array(), \'20151112\', true );
}
if(is_single(3703)){
wp_enqueue_script( \'uiProbs\', get_template_directory_uri() . \'/js/uiProbs.js\', array(), \'20151112\', true );
}
wp_enqueue_script( \'ciquiz\', get_template_directory_uri() . \'/js/ciquiz.js\', array(), \'20151112\', true );
wp_enqueue_script( \'geoMean\', get_template_directory_uri() . \'/js/geoMean.js\', array(), \'20151112\', true );
wp_enqueue_script( \'jquery-2.2.4.min\', get_template_directory_uri() . \'/js/jquery-2.2.4.min.js\', array(), \'20151112\', true );
wp_enqueue_script( \'jquery-3.1.0.min.js\', get_template_directory_uri() . \'/js/jquery-3.1.0.min.js\', array(), \'20151112\', true );
wp_enqueue_script( \'custSampSize.js\', get_template_directory_uri() . \'/js/custSampSize.js\', array(), \'20151112\', true );
wp_enqueue_script( \'actb.js\', get_template_directory_uri() . \'/js/actb.js\', array(), \'20151112\', true );
// wp_enqueue_script( \'color-scheme-control\', get_template_directory_uri() . \'/js/color-scheme-control.js\', array(), \'20151112\', true );
//wp_enqueue_script( \'compSUSRegress\', get_template_directory_uri() . \'/js/compSUSRegress.js\', array(), \'20151112\', true );
//wp_enqueue_script( \'customize-preview\', get_template_directory_uri() . \'/js/customize-preview.js\', array(), \'20151112\', true );
wp_enqueue_script( \'html5\', get_template_directory_uri() . \'/js/html5.js\', array(), \'20151112\', true );
//wp_enqueue_script( \'keyboard-image-navigation\', get_template_directory_uri() . \'/js/keyboard-image-navigation.js\', array(), \'20151112\', true );
wp_enqueue_script( \'klm\', get_template_directory_uri() . \'/js/klm.js\', array(), \'20151112\', true );
wp_enqueue_script( \'myscript\', get_template_directory_uri() . \'/js/myscript.js\', array(), \'20151112\', true );
wp_enqueue_script( \'myselect2\', get_template_directory_uri() . \'/js/myselect2.js\', array(), \'20151112\', true );
//wp_enqueue_script( \'npsMeanRegress\', get_template_directory_uri() . \'/js/npsMeanRegress.js\', array(), \'20151112\', true );
if(is_single(230))
{
wp_enqueue_script( \'npsMeanRegress\', get_template_directory_uri() . \'/js/npsMeanRegress.js\', array(), \'20151112\', true );
wp_enqueue_script( \'npsSUSMeanRegress\', get_template_directory_uri() . \'/js/npsSUSMeanRegress.js\', array(), \'20151112\', true );
}
wp_enqueue_script( \'organic\', get_template_directory_uri() . \'/js/organic.js\', array(), \'20151112\', true );
wp_enqueue_script( \'skip-link-focus-fix\', get_template_directory_uri() . \'/js/skip-link-focus-fix.js\', array(), \'20151112\', true );
wp_enqueue_script( \'jquery-1.10.2\', get_template_directory_uri() . \'/js/jquery-1.10.2.js\', array(), \'20151112\', true );
/* 09.02.2017 end */
wp_enqueue_style( \'custom-style\', get_template_directory_uri() . \'/css/custom.css\', array(), false, \'\' );
if ( is_singular() && comments_open() && get_option( \'thread_comments\' ) ) {
wp_enqueue_script( \'comment-reply\' );
}
if ( is_singular() && wp_attachment_is_image() ) {
wp_enqueue_script( \'twentysixteen-keyboard-image-navigation\', get_template_directory_uri() . \'/js/keyboard-image-navigation.js\', array( \'jquery\' ), \'20151104\' );
}
wp_enqueue_script( \'twentysixteen-script\', get_template_directory_uri() . \'/js/functions.js\', array( \'jquery\' ), \'20151204\', true );
wp_enqueue_script( \'twentysixteen-jquery\', get_template_directory_uri() . \'/js/jquery-1.12.0.min.js\', array( \'jquery\' ), \'\', true );
wp_enqueue_script( \'twentysixteen-boot\', get_template_directory_uri() . \'/js/bootstrap.js\', array( \'jquery\' ), \'\', true );
wp_enqueue_script( \'twentysixteen-owl\', get_template_directory_uri() . \'/js/owl.carousel.js\', array( \'jquery\' ), \'\', true );
wp_enqueue_script( \'twentysixteen-main\', get_template_directory_uri() . \'/js/main.js\', array( \'jquery\' ), \'\', true );
wp_localize_script( \'twentysixteen-script\', \'screenReaderText\', array(
\'expand\' => __( \'expand child menu\', \'twentysixteen\' ),
\'collapse\' => __( \'collapse child menu\', \'twentysixteen\' ),
) );
}
add_action( \'wp_enqueue_scripts\', \'twentysixteen_scripts\' );
所有这些都有效。现在,我想让另一个文件排队。此外,我想让它有条件地加载,除了首页以外的任何地方,但在这一点上,我很乐意让它加载!
首先,我尝试了条件版本(if ! is_front_page...)
但不起作用(我让它起作用header.php
, 但我希望它在其他一切之后加载)。考虑到我的代码中可能有错误,我尝试将文件排队以查看其加载情况。。。。什么都没有。尝试了我能想到的一切。。。什么都没有。
因此,作为最后一个资源,我尝试替换实际加载的一个文件,custom-style --> css/custom.css
虽然听起来很奇怪,但它什么也没做。此外,如果我检查来源,即使如此css/custom.css
不应该在那里,现在还在。Just in case: I don\'t have any cache and I can see any other changes that are not related to this file.
最后,我尝试创建一个不同的函数来将文件排队,但什么都没有,根本不起作用。
这是我无意中添加的代码:
{wp_enqueue_style( \'blog-styles\', get_template_directory_uri() . \'full-style.css\', array( \'twentysixteen-style\' ), \'20170410\' );}
最后,基于
this answer 我尝试了这个,这也有助于条件部分:
add_action(\'init\', \'my_register_styles\');
function my_register_styles() {
wp_register_style( \'style1\', get_template_directory_uri() . \'/style.css\' );
wp_register_style( \'style2\', get_template_directory_uri() . \'/full-style.css\' );
}
add_action( \'wp_enqueue_scripts\', \'my_enqueue_styles\' );
function my_enqueue_styles() {
if ( is_front_page() ) {
wp_enqueue_style( \'style1\' );
} else {
wp_enqueue_style( \'style2\' );
}
}
但正如你现在可能想象的那样。。。。没用!
问题是什么导致了这种情况?我做错了什么有没有办法让样式表加载到标题上。排队脚本之后的php