I would want to show some HTML code in my WordPress page. So in my child theme functions.php
, I have written an action like this one:
add_action('wp', function() {
if(is_admin()) {
return;
}
$html = '<div class="home_immodvisor">';
echo $html;
});
However, a warning is displayed when I go to the back-office (admin) login page:
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/themes/hello-elementor-child/functions.php:88) in /var/www/html/wp-includes/pluggable.php on line 1296
Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wp-content/themes/hello-elementor-child/functions.php:88) in /var/www/html/wp-includes/pluggable.php on line 1299
My question is: is it the good action to hook? Or should I use another one than wp
?
From my understanding wordpress sends headers after wp so this is the wrong place, since you cannot echo before.