admin管理员组

文章数量:1125938

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.

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.

Share Improve this question asked Jan 30, 2024 at 6:51 SS AppsSS Apps 31 bronze badge 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. – Tony Djukic Commented Jan 31, 2024 at 4:13
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Bot Commented Jan 31, 2024 at 4:13
Add a comment  | 

1 Answer 1

Reset to default 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.

本文标签: Changable favicon based on postfeatured image