Support » Plugins » [Plugin: Advertisement Manager] Filtering ads works erratic/breaks ads on pages

  • carlos_wp



    I’m using the “Website display options” drop-down menus to prevent the ads from showing on certain posts. But it doesn’t work most of the time: i’ve tried filtering both by categories and tags, single, multiple, combined… and sometimes it works, sometimes it doesn’t (when it works, the affected ads don’t appear, when it doesn’t, the ads appears as always). I can’t find a pattern for this behaviour.

    While trying to find out the reason, I’ve found out that, when I try to filter the ads as I have mentioned (from website display options), and the filter doesn’t work, there happens something more: an error appears on pages (pages, not posts). The error says:

    Warning: Invalid argument supplied for foreach() in /home2/establed/public_html/wp-content/plugins/advertising-manager/lib/OX/Ad.php on line 168

    At first, I didn’t know it was related to trying to filter ads,but while checking line 168 at ad.php, I located this:

    foreach ($categories as $category) {
    				if (in_array($category->cat_ID, $categoryFilter)) {

    so, although I’m php-illiterate, I guessed it had to do with trying to filter ads. Maybe it has something to do with pages not having categories? Anyway, removing the filter (checking all tags and categories again for each ad) made the error go away from pages. But I still can’t filter ads selectively based upon tags or categories.

    I know this is a bit generic, but I would like some idea about what to try, or which could be the reason for the filtering acting erratic (works for some tags/categories, doesn’t work for others). If there’s any extra info I may contribute, please let me know.

    I’m using wp 3.0.1 and a modified mistylook theme. Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • carlos_wp


    It’s me again… I think I’ve found a workaround that seems to work, and I thought it could be useful to share it, in case more people runs into the same problem. I have created a new user and I have changed the “author” field of the few posts where I don’t want ads, so the new user is now “him” instead of me. Then, I have edited the options for the ads and filtered them so that they don’t show for posts/pages where the author is the new user.

    This posts aren’t showing ads after doing this, and pages are not broken since they do have an author. So, it’s working! 🙂

    Anyway, either I was doing something wrong when manipulating the tags/categories filter, or there is some kind of bug – if the latter is true, it would be nice that Scott (the author of the plugin) could fix it sometime in the future. I’ve tried several adsense plugins, and personally I like his the most. Thanks Scott!



    I had this problem with tags. I edited the code in the file Ad.php in the folder advertising-manager/lib/OX/Ad.php.

    If tags weren’t defined, and if I had unclicked ‘tags’ for a particular ad, it would throw an error. I just added an if statement to test that it had a tag before it processes the foreach statement.

    //add the if statement because if $tags wasn't defined it was throwing an error
    if ($tags) {
        foreach ($tags as $tag) {
            if (in_array($tag->term_id, $tagFilter)) {
                $found = true;

    This solved a similar issue for me.



    Thanks a lot Brian. I can’t check whether it works or not for me, tho, since I was banned from the adsense program for unknown reasons briefly after posting the above question (not even 2 weeks since signing up for adsense!). Anyway, as I say, thanks a a lot for your help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Advertisement Manager] Filtering ads works erratic/breaks ads on pages’ is closed to new replies.