Trying to create a plugin to change wordpress site icons per page
I am trying to create a plugin to alter a WordPress websites default site icon set under appearancecustomize.
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');
?