How to add code to head section of homepage
-
I know this question has been asked before, but the solutions posted don’t work for me.
I’m using Genesis with the FoodiePro child theme. I want to add the following open graph meta tags to the head of my homepage only:
<meta property=”og:title” content=”Sentence Spotlight” />
<meta property=”og:site_name” content=”Sentence Spotlight” />
<meta property=”og:url” content=”sentencespotlight.com” />
<meta property=”og:description” content=”I pick good sentences and think about why they work.” />
<meta property=”og:image” content=”https://www.theperfectpoach.com/wp-content/uploads/2015/03/Sentence-Spotlight-Logo.jpg” />FoodiePro doesn’t have its own header.php, so I copied the header.php from Genesis, and added the following php code:
if (is_front_page() ) {
echo “<meta property=”og:title” content=”Sentence Spotlight” />
<meta property=”og:site_name” content=”Sentence Spotlight” />
<meta property=”og:url” content=”www.sentencespotlight.com” />
<meta property=”og:description” content=”I pick good sentences and think about why they work.” />
<meta property=”og:image” content=”https://www.theperfectpoach.com/wp-content/uploads/2015/03/Sentence-Spotlight-Logo.jpg” />”;
}I inserted this after an opening php code and before a closing php tag and a closing head tag. Then I uploaded my new header.php file to the FoodiePro directory. Afterwards, I could still access the admin sections of my site, but the front end was blank.
Site is https://www.theperfectpoach.com (a test site). Thanks for your help!
- The topic ‘How to add code to head section of homepage’ is closed to new replies.