Is it possible to put Favicon on a specific page ? For example : mywebsite.com/blog1 -> Favicon1 mywebsite.com/blog -> Favicon2 And so on.

Because later I'll put custom domain name for each blog (And I don't want to put the same Favicon on these pages)

Thanks for your help !

  • Why not? Just set the appropriate meta tags and see what the browser make of it. – janh Feb 5 '18 at 12:29
  • I really don't know where to put that meta tags because I want a specific favicon for a specific page, if I add a meta tag in the template it will be generic, right ? – Charboter Feb 5 '18 at 12:53
  • Yes, but you can use conditional tags like is_single(123) that is only true if the post with the ID 123 is currently shown to fine tune what to show. – janh Feb 5 '18 at 13:00

You can use a few solutions;

  1. Create meta-field with favicon in your page/post. And call this in your header.php file. But dont forget set default value, if meta-field will be empty.
  2. Wrap this meta tags in apply_filter and create filters for this.
  3. Use conditionals like is_page(), is_singular('product') etc..
  4. Remove meta tags from header.php and use add_action('wp_head', 'your_functions_tags');
  5. Create header-{slug}.php. header-fav1.php, header-fav2.php and call in your template like <?php get_header('fav1'); ?>

Something for this list must help you.

  • Its very kind and I'm sure that working, but I really can't figure out how to make this working, I never before work with this kind of meta in Wordpress. I tried to read some article about it but it's like "black magic" for me. Anyway, thanks for your time. – Charboter Feb 5 '18 at 13:40
  • Read about meta fields. And template files. Easier way - Advaced Custom Fields plugin. – Maxim Sarandi Feb 5 '18 at 13:43
  • Thanks for your advice. I read carefully these articles : codex.wordpress.org/Conditional_Tags pagely.com/blog/find-post-id-wordpress wpbeginner.com/wp-tutorials/… code.tutsplus.com/tutorials/… developer.wordpress.org/themes/basics/template-files Maybe I'm just dumb about this but, I understand each of point you mentioned but I don't understand how to correctly implement this. – Charboter Feb 5 '18 at 16:31
  • Okay so I make it worked with this : if ( get_the_ID() == 27) { ?> <link rel="icon" href="mylink" sizes="32x32" /> <?php } ?> But when I look at the source code generated, it displays first my main favicon and just after mine...Is there a way to conditional the favicon display of the main site ? – Charboter Feb 5 '18 at 17:31

This might be overkill, but if you are looking to swap out favicons for specific pages, post archives, or even single posts, here is something that should get you there. Hopefully it's clean enough to maintain. And you can drop in whatever sort of is_ conditional WordPress has to offer.

    case is_page(27) :
      $favicon_link = 'link_to_favicon_one.png';
    case is_page(array(23, 40, 44, 60)) :
      $favicon_link = 'link_to_favicon_two.png';
    case is_post_type_archive() :
      $favicon_link = 'link_to_favicon_three.png';
    case is_single(2001) :
      $favicon_link = 'link_to_favicon_four.png';
    default : // Always need a fallback
      $favicon_link = 'link_to_favicon.png';

<link rel="icon" href="<?=$favicon_link?>" sizes="32x32" /> 

Hope this helps someone!

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.