只有在帖子或页面中包含视频或声音并且在wp\\u head之后才加载这两个样式表。
但不要绝望!有一个过滤器你可以使用!代码中如下所示:
apply_filters( \'style_loader_tag\', "<link rel=\'$rel\' id=\'$handle-css\' $title href=\'$href\' type=\'text/css\' media=\'$media\' />\\n", $handle );
所以我写了一个函数:
//add the filter
add_filter( "style_loader_tag", "change_css_links", 10, 2 );
// Function for the filter
function change_css_links($css, $handle){
//load global styles to get src
global $wp_styles;
//check if it is the correct style
if($handle == "mediaelement" || $handle == "wp-mediaelement"){
//if it is: do awesome stuff
// get all info for the css in array
$css_info = $wp_styles->registered[$handle];
//the array looks like this:
/*
[mediaelement] => _WP_Dependency Object
(
[handle] => mediaelement
[src] => /wp-includes/js/mediaelement/mediaelementplayer.min.css
[deps] => Array
(
)
[ver] => 2.13.0
[args] =>
[extra] => Array
(
)
)
*/
// do the awesome
$css = "your new and awesome link element!";
}
//return the new or old awesome!
return $css;
}
或者,您可以取消注册样式并在每个页面上加载它们。