【问题标题】:How do I change linked stylesheets?如何更改链接样式表?
【发布时间】:2017-03-06 21:17:42
【问题描述】:

在我的 WordPress 主题的 <head></head> 之间有一个指向 google 字体样式表的断开链接。如何删除或更改链接?在index.php 中,它只显示wp_head()

<link rel='stylesheet' id='tesseract-fonts-css' href='//fonts.googleapis.com/css?family=Open%2BSans%3A400%2C‌​300%2C300italic%2C40‌​0italic%2C600%2C600i‌​talic%2C700%2C700ita‌​lic%2C800%2C800itali‌​c%26subset%3Dlatin%2‌​Cgreek%2Cgreek-ext%2‌​Cvietnamese%2Ccyrill‌​ic-ext%2Ccyrillic%2C‌​latin-ext' type='text/css' media='all' />

这是网址:

http://fonts.googleapis.com/css?family=Open%2BSans%3A400%2C‌​300%2C300italic%2C40‌​0italic%2C600%2C600i‌​talic%2C700%2C700ita‌​lic%2C800%2C800itali‌​c%26subset%3Dlatin%2‌​Cgreek%2Cgreek-ext%2‌​Cvietnamese%2Ccyrill‌​ic-ext%2Ccyrillic%2C‌​latin-ext

【问题讨论】:

  • 您能否指定您认为已损坏的 指向 google 字体样式表的链接 的 url?
  • 我一回到家就贴上去。

标签: php html css wordpress


【解决方案1】:

样式表将使用wp_register_style 加载,可能在functions.php 中

【讨论】:

  • 感谢您的快速回复,我一回到家就去看。
  • 通过functions.php彻底搜索,没有找到wp_register_style。
  • 我错了,它在那里 wp_enqueue_style( 'tesseract-fonts', tesseract_fonts_url(), array(), '1.0.0' );
【解决方案2】:

取消注册/出列样式是最佳实践

https://codex.wordpress.org/Function_Reference/wp_deregister_style https://codex.wordpress.org/Function_Reference/wp_dequeue_style

但是你也可以使用这个过滤器,过滤掉任何条件的样式:

add_filter( 'style_loader_src', function($href){
if(strpos($href, "name-of-allowed.css") !== false) {
return $href;
}
return false;
});

【讨论】:

    猜你喜欢
    • 2017-10-10
    • 2021-09-15
    • 1970-01-01
    • 2021-10-22
    • 1970-01-01
    • 1970-01-01
    • 2020-02-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多