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?
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?
Share Improve this question edited Feb 15, 2021 at 0:52 Rup 4,4004 gold badges29 silver badges29 bronze badges asked Feb 15, 2021 at 0:06 Jerry FleurivalJerry Fleurival 32 bronze badges 8
code
**add_action('wp_head', 'my_favicon'); function my_favicon() { // echo "<link rel='shortcut icon' href=' " . get_stylesheet_directory_uri() . '/images/favicon.ico'"'>"; } **code
– Jerry Fleurival Commented Feb 15, 2021 at 0:30'/images/favicon.ico'"'
should be"'/images/favicon.ico'
. And thehref
should have no whitespace at the beginning, so usehref='"
. – Sally CJ Commented Feb 15, 2021 at 0:39"/images
. But why don't you just use the Customizer → Site Identity → Site Icon to set the site icon (or favicon)? – Sally CJ Commented Feb 15, 2021 at 1:42