I am testing Google AdSense Auto Ads, the ad code is inserted in the header.php file so it appears on all pages. I do not want the ads to show on the 404 page, so the following code was suggested and inserted in the header:
<?php if (!is_404()) { ?>
AdSense Auto Ad code is here
<?php } ?>
This does not seem to be working, is there a better solution to blocking ads in the header file only on 404 error pages?
Thank you in advance.