简体   繁体   English

wp_enqueue_style将输出CSS直接放置在HTML中

[英]wp_enqueue_style places the output CSS directly in the HTML

I am using wp_register_style and wp_enqueue_style to add stylesheets to my custom theme. 我正在使用wp_register_stylewp_enqueue_style将样式表添加到我的自定义主题。 Locally it works as expected, however, on my staging machine instead of adding a link to the CSS file I have specified, it places the CSS directly in my HTML, like: 在本地它可以按预期工作,但是,在我的登台计算机上,而不是向我指定的CSS文件添加链接,而是将CSS直接放置在HTML中,例如:

<style id="titilium-font-css" media="all">
  /* CSS styles here */
</style>

Here is how I enqueue my styles: 这是我如何加入样式的方法:

add_action( 'wp_enqueue_scripts', array( $this, 'register_styles' ) );

function register_styles() {
  wp_register_style( 'titilium-font', 'http://fonts.googleapis.com/css?family=Titillium+Web:400,600,700' );
  wp_enqueue_style( 'titilium-font' );
}

I expect the output to be (and it is locally): 我希望输出是(它是本地的):

<link rel="stylesheet" id="titilium-font-css" href="http://fonts.googleapis.com/css?family=Titillium+Web%3A400%2C600%2C700&amp;ver=4.0.2" type="text/css" media="all">

Any hints what to look for on the staging machine in order to solve this? 有什么提示要在登台机器上寻找什么来解决这个问题?

Ok, this behaviour was caused by the mod_pagespeed enabled on the Apache server on the Staging machine. 好的,此现象是由登台计算机上的Apache服务器上启用的mod_pagespeed引起的。 I wish I knew about we having this thing enabled form the start. 我希望我从一开始就知道我们启用了此功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM