WordPress.org

Support

Support » Plugins and Hacks » Advertising Manager » [Resolved] [Plugin: Advertising Manager] Problem using Homepage filter

[Resolved] [Plugin: Advertising Manager] Problem using Homepage filter

  • I was having a problem using the Homepage filter because my homepage is actually a static page. Since it’s a page, the Page filter was overriding the Homepage filter. I edited the code in ‘plugins/advertising-manager/lib/OX/ad.php’ to the following in order to fix the situation.

    //Extend this to include all ad-specific checks, so it can used to filter adzone groups in future.
    $pageTypes = $this->get_property('show-pagetype');
    
    if (!empty($pageTypes)) {
    
        //switched from is_home because this the theme we use, uses a static front page for the home page
        if (is_front_page() && !in_array('home', $pageTypes)) {
            return false;
        }
        if (is_single() && !in_array('post', $pageTypes)) {
            return false;
        }
        //added is_front_page since the home page happens to also be a page
        if (is_page() && !is_front_page() && !in_array('page', $pageTypes)) {
            return false;
        }
        if (is_archive() && !in_array('archive', $pageTypes)) {
            return false;
        }
        if (is_search() && !in_array('search', $pageTypes)) {
            return false;
        }
    }
    
    return true;

    In the first conditional I’m using is_front_page() instead of is_home().

    Then in the 3rd conditional I’ve added ‘&& !is_front_page()’ so that it will test to see if the visitor is on a ‘Page’ but not the ‘Front Page’.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thank you! I have been trying to figure this out for hours! Works wonderfully.

    klagreca

    @klagreca

    I’m having a slightly similar issue. My front page is “latest posts” (which pulls the index.php file from the template directory). The “homepage” filter is not working for me either, but I don’t think Brian’s fix is the right one for me. Scott, any suggestions?

    Thanks!

    klagreca

    @klagreca

    quick update: The ad only shows if I turn on the “pages” filter. It will not show with the “homepage” or “posts” filter, even if I’m on a post page.

    My theme is based on TwentyTen, and I’m using AM v3.4.19 on WP3.0.1

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] [Plugin: Advertising Manager] Problem using Homepage filter’ is closed to new replies.
Skip to toolbar