Problem with custom function that adds Post Avatar og:image
-
I’m using a function added to my child theme’s function.php file for the purpose of adding the Post Avatar image to Facebook’s required meta property og:image list in the url.
The code was suggested in this forum exchange, and I used it and it worked. However, I just noticed that when there is no Post Avatar on the page, it leaves a line like this:
<meta property=”og:image” content=””/>
…and Facebook doesn’t like that. Their debugger says:
Errors That Must Be Fixed
Object Missing a Required Value Object at URL ‘https://www.humortimes.com/34003/humor-times-founder-editor-to-appear-on-radio-paralax-show-april-2nd/’ of type ‘article’ is invalid because a required property ‘og:image:url’ of type ‘url’ was not provided.What can I do to address this? Can I add an ‘else’ statement to the function, so that if there is no avatar, there’s a default image to use?
- The topic ‘Problem with custom function that adds Post Avatar og:image’ is closed to new replies.