Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Tsunamijaan/6388cea8fd875c71e1c53b03427882c9 to your computer and use it in GitHub Desktop.
Save Tsunamijaan/6388cea8fd875c71e1c53b03427882c9 to your computer and use it in GitHub Desktop.
How to add favicon in wordpress website?
Make sure you used this before </head>
If you have favicon as .ico format, you can use this code.
<link type="image/x-icon" rel="shortcut icon" href="<?php echo get_template_directory_uri(); ?>/img/favicon.ico">
If you have favicon as png image format, you can use this code. Make sure your favicon size is 16x16px
<link rel="shortcut icon" type="image/png" href="<?php echo get_template_directory_uri(); ?>/img/favicon.png"/>
You can register favicon via functions.php too. See this code
function my_theme_add_favicon(){ ?>
<!-- Custom Favicons -->
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri();?>/img/favicon.ico"/>
<?php }
add_action('wp_head','my_theme_add_favicon');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment