Question

When I put this code in my functions.php

add_action('wp_head', 'my_favicon');
function my_favicon() {
    echo "<link rel='shortcut icon' href=' " . get_stylesheet_directory_uri() .
         '/images/favicon.ico'"'>";
}

I get

[Message from webpage]: There has been a critical error on this website. Learn more about debugging in WordPress.

What's wrong with my code?

Was it helpful?

Solution

add_action('wp_head', 'my_favicon');
function my_favicon() {
    echo "<link rel='shortcut icon' href='" . get_stylesheet_directory_uri() .
         "/images/favicon.ico'>";
}

I think the problem was incorrect quotation marks on the string. Can you try this code.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top