0

its possible use to change the favicon on based the post-featured image icon? I use 100x100 size or 64x64 icon images on my posts. I want these icons to show as a favicon also. if some posts not have featured images then show our default favicon. help me out how to this work through ad-filter or ad-action.

2
  • From what I know, while this COULD be done, it's not a good idea and it'd probably be unreliable because most browsers put heavy caching on favicons. But, basically, what you'd want to do is just add the favicon code with paths to the images with the wp_head action. But, how are you going to get WP to auto-generate all the different required favicon files when you upload featured images? Like the featured-image-favicon.ico? And I think that the apple-touch-icon.png has to always be named apple-touch-icon.png - so you may not be able to do this properly for all platforms/browsers. Jan 31 at 4:13
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    Jan 31 at 4:13

1 Answer 1

0

You can use the wp_head action to print code in the <head> block of each document. If your theme does not use the wp_head() function, then dropping do_action( 'wp_head' ) into your <head> block is required.

Simplest way would be to wrap the favicon's URL in a filter, and then change that depending on the current post being viewed. Note you'll likely need to take measures to prevent caching of the favicon, which in my experience can be a challenge.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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