I am looking for help to put single page favicon that would overwrite global one. Say for example I have wordpress website that is example and it has favicon set for every page. What I want is for example/page3 to have diffrent favicon. I have seen quite a few options around but I cannot figure out how to make it work (my coding skills are limited). This solution:
<?php
echo '<link rel="shortcut icon" href=".ico?t=' . time() . '" />';
?>
Is marked as working one, but I cannot figure out how to set it up. Thank you for help
I am looking for help to put single page favicon that would overwrite global one. Say for example I have wordpress website that is example and it has favicon set for every page. What I want is for example/page3 to have diffrent favicon. I have seen quite a few options around but I cannot figure out how to make it work (my coding skills are limited). This solution:
<?php
echo '<link rel="shortcut icon" href="http://www.yoursite/favicon.ico?t=' . time() . '" />';
?>
Is marked as working one, but I cannot figure out how to set it up. Thank you for help
If you have a modern theme, where you can upload a favicon with the theme customizer (rather than a hardcoded url in the header.php
), you can simply use a filter. Take a look at the function get_site_icon
. As you can see it returns the url of the image that you have uploaded using the customizer. However, before it does so, it runs it through a filter, allowing you to change it under any condition you would like. For instance, to change it when you are on a page with ID=3:
add_filter( 'get_site_icon_url','wpse318165_filter_favicon', 10, 3 );
function wpse318165_filter_favicon ($url, $size, $blog_id) {
global $post;
if ( is_page( 3 ) ) $url = 'path-to-other-favicon';
return $url;
}
Here is the link: https://elementor/blog/header-footer-builder/
there is a video link on this page which explains how can you create/use multiple header with Elementor plugin.
Normally if you have FTP access go to theme folder and duplicate header.php and name it something relevant ie. header-blog.php
Then you can call that file in your page/templates via <?php get_header('blog); ?>
In your new header file use the rel link you've got for custom favicon. That's it :)