Add conditional PHP code in the header?

Posted in: Newspaper
Post count: 72

Can I add a conditional PHP the header of the site anywhere in the Theme Panel? I want to add this:

<?php if ( in_category('15') ) : ?>
<meta name="googlebot-news" content="noindex, nofollow">
<?php endif ; ?>

So I only want that to appear in the <head> for any posts within that one category so Google does not index it. It seems like no way to do this/ So I can only create a header.php in the child theme to do this?

Post count: 35449

Hi,

You can do that manually, please go in Appearance>Editor and select Theme Header, you can put your code there, but be notice when you’ll update the theme you need to do this again.

Thanks.

Post count: 72

Thank you, but I don’t understand why it would be erased if I update the Newspaper them? I don’t think I ever had this problem before when I updated a theme… if it truly is removed, then it’s best for me to do a header.php in a Child theme.

Post count: 35449

Yes, you can do that, then you’ll never have to worry about it.

Post count: 72

Hi, but I’m still unclear why updating a theme would wipe out the changes in the Appearance>Editor? Why would that happen? That’s not supposed to happen.

Post count: 35449

Hi,

That will happen because the updated will override the files from theme.

Thank you for your understanding.

Viewing 6 posts - 1 through 6 (of 6 total)
The forum ‘Newspaper’ is closed to new topics and replies.