简体   繁体   English

如何更改链接的样式表?

[英]How do I change linked stylesheets?

Inbetween the <head></head> of my WordPress theme is a broken link to a google font stylesheet. 我的WordPress主题的<head></head>之间是指向Google字体样式表的断开链接。 How do I either remove the link or change it? 如何删除链接或更改链接? In the index.php it's just showing wp_head() . 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' />

This is the URL: 这是URL:

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 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‌C越南语%2Ccyrill‌ic-ext%2Ccyrillic%2C‌latin-ext

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

Deregister/Dequeue styles is best practice 取消注册/出队样式是最佳做法

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

But you can use this filter too, to filter out styles with any condition: 但是您也可以使用此过滤器,以过滤掉任何条件的样式:

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

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

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