Display an image on post page if NOT specific category
-
I’m just a WordPress user, but am trying to may some tweaks to my pages. On my post pages (single.php) I would like to display an image in the post unless it is in a particular category. Just picking up tidbits here and there, this is what I tried:
————<?php $findme = 'My Category'; $pos = strpos($category->cat_name, $findme); if ($pos === false) { echo '<a href="https://www.test.com/"><img class="alignright right size-full wp-image-34" title="Test" src="https://www.test.com/test.gif" alt="Image Link" width="228" height="152" /></a>'; } ?>
————-
The result I am getting is that it displays the image no matter what the category or categories of the post. When I did “echo $pos”, it didn’t display anything.Any help would be greatly appreciated. Specific code would be wonderful! I don’t really know PHP and am just getting my feet wet.
Thanks!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Display an image on post page if NOT specific category’ is closed to new replies.