admin管理员组文章数量:1287513
I am trying to create a plugin to alter a WordPress websites default site icon set under appearance>customize.
I am unable to find and good resources/examples on how to modify the existing site icon urls for the 4 different sizes created by default.
I've read a lot on the different built in functions but can't put it together to get anything working. I currently have a case statement to check page id and then change the url ($favicon_link variable) to the site icon I want for certain pages that way but this doesn't account for the auto generated different sizes of icon wordpress normally creates.
Any direction would be much appreciated.
<?php
function wp_custom_icon_favicon_per_page ($meta_tags){
//$meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags );
//Change base url depending on page ID
switch(true){
case is_page(9) :
$favicon_link = 'http://localhost/testwp/wp-content/uploads/2021/11/Logo2.png';
break;
case is_page(15) :
$favicon_link = 'http://localhost/testwp/wp-content/uploads/2021/11/Logo3.png';
break;
default : // Always need a fallback
$favicon_link = 'http://localhost/testwp/wp-content/uploads/2021/11/Logo1.png';
break;
}
//Edit existing meta tags
}
//add_filter ( 'site_icon_meta_tags', 'wp_custom_icon_favicon_per_page');
add_action('wp_head', 'wp_custom_icon_favicon_per_page');
?>
本文标签: faviconTrying to create a plugin to change wordpress site icons per page
版权声明:本文标题:favicon - Trying to create a plugin to change wordpress site icons per page 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741221913a2361120.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论