Add Custom Favicon Without Plugin to give your WordPress site a unique icon in the browser tab. Here’s how to do it with a simple snippet.
Step 1: Add the Favicon Code
Add this to your child theme’s functions.php:
// Add custom favicon
function qdt_custom_favicon() {
echo ‘<link rel="icon" href="' . get_stylesheet_directory_uri() . '/favicon.ico" type="image/x-icon" />‘;
}
add_action(‘wp_head’, ‘qdt_custom_favicon’);
How It Works
This function inserts a favicon tag into your site’s <head> section, pointing to your custom favicon file in your theme folder.
Why Add Custom Favicon Without Plugin?
A favicon boosts your brand recognition and helps users spot your site in browser tabs. Adding it with a snippet keeps your site light and free from extra plugins.
Common Mistake
Make sure your favicon.ico file is uploaded to your child theme directory and the path matches. Use the right file type for modern browsers (.png or .svg if needed).
Pro Tip
For modern browsers, you can add multiple icon sizes and types for better compatibility.
Related Snippet
If you liked this, check out my guide on removing the WordPress version without a plugin.