Peter
Peter

Reputation: 19

Don't have access to head - Need to Add Meta OG Tags by either JQuery/PHP

I know this method isn't ideal, but I have no alternative. I can't access the head, and I need to add OG tags to a page. I tried simply embedding them into the page on the off-chance that it might work, but I only received a warning about the error in the Facebook Debugger.

I tried to add them to the head by javascript, but that all works on the surface since that appears after the page has loaded....I assume PHP would be the only practical way to add in the og:title, og:image, and og:description I need.

Does anyone know if/how it is possible to add the meta tags to the head so that Facebook will detect them? Again, I know this isn't the best way to go about it, but I only have access to the body content. Greatly appreciate any help!

Upvotes: 1

Views: 1097

Answers (1)

andyrandy
andyrandy

Reputation: 73984

The Facebook bot does not call JavaScript, so the Open Graph Tags can´t be added with JavaScript. Your need to add them in your PHP code, but you can´t do that AFTER page load - that´s not how PHP works.

Also, use the debugger to check if the Open Graph Tags are correct: https://developers.facebook.com/tools/debug/

Upvotes: 1

Related Questions