Display og:image if category selected
-
I want to display a certain og image if a certain category is chosen for a post. I do it like this:
if (has_category(1)) { $image = pathtoimage; }
then I would use that variable to display the og:image through my html
Now the problem is that this only works whenever there are more then one category selected then slug id 1 so whenever category slug 1 is ONLY selected, the og:image wont show. Am I using has_category wrong?
Thanks a ton
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Display og:image if category selected’ is closed to new replies.