0

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.com and it has favicon set for every page. What I want is for example.com/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.com/favicon.ico?t=' . time() . '" />';
?>

Is marked as working one, but I cannot figure out how to set it up. Thank you for help

  • You can add a new header for page3 and have different favicon rel link for that. – Hardik Bhatt Nov 1 '18 at 10:32
  • Thank you for answer but how can I do that? Page have header built with Elementor page builder. – Perovic Nov 1 '18 at 11:42
1

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;
  }
-1

Here is the link: https://elementor.com/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 :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.