Trying to retrieve all categories of all posts that will be displayed
Long time reader, first time poster 😉
So I have this problem I’m trying to solve. My end goal is to have Adsense ads above my content area and to the right of my content area, so I’m using my theme’s (Mystique) header code option and a sidebar text widget to display them. The caveat is that I have a handful of posts whose content will violate Google’s content terms.
Having already spoken with somebody at Google to verify that I can still use Adsense on the site as long as it’s not displayed on the same page as the violating content, I figured the easiest solution would be to have a category/tag to mark posts as being not-Adsense-safe. Then, in the code that displays the ads, just have it perform a check (in PHP land I assume) to see if any posts of that category are present on the current page and, if so, skip displaying the ads (or pick something non-Adsense if I ever decide to use other ad networkd).
Cool, seems like a simple enough solution. I’m currently trying to use
get_the_category()and just loop through the results, checking each one as I go. The problem I’m having is that
get_the_category()only seems to return categories for the current post unless a post ID is passed.
- The topic ‘Trying to retrieve all categories of all posts that will be displayed’ is closed to new replies.