Getting an error. Need to add favicon in my child theme functions.php. What's wrong?
-
22-04-2021 - |
Pergunta
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?
Solução
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange