• superfrappe

    (@superfrappe)


    Hi,

    I have an ad positioned in the right rail of my theme contained in an HTML widget. I currently have two companies that have ads served in that position across the site. One of the companies does not want their ad to show up on any page that contains comments (or even for that matter if comments are enabled).

    If the case was that I wanted no ads on a page with comments, I can see how that can be done. But in this case, I need to only hide (or not serve) an ad from a certain company. Can this be done? Appreciate any help!

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • vjpo

    (@vjpo)

    One pretty simple way is to use a plugin like Widget Logic. It uses WP conditional tags.
    Examples:
    is_singular() && !comments_open() – to display certain widget on posts and pages with closed commenting.
    is_page() && !have_comments() – to display a widget only on pages and if no comments there.
    If you have two different ads in one widget, you can try some php widget plugin.

    vjpo

    (@vjpo)

    I forgot this… ?? to display everywhere except pages and posts with comments
    !(is_singlular() && have_comments())

    Thread Starter superfrappe

    (@superfrappe)

    Hi vjpo,

    Thanks for your feedback! Some great ideas there but here’s where you are right on about what I need:

    “If you have two different ads in one widget, you can try some php widget plugin.”

    Right on the money. I need to have both rotating ads in one widget, yet make sure one of the company ads wont appear on pages with comments. That’s the challenge. A real pain if you ask me.

    Thanks again for your help!

    vjpo

    (@vjpo)

    Hello, superfrappe,
    it shouldn’t be a problem with php widget plugin. The way is almost the same – using WP conditional tags, but with full php syntax. Just succefully tested it with WP PHP widget on WP 3.5.1
    Example how it works. Add it into php widget

    <?php if( ! ( is_singular() && have_comments() ) ) : ?>
    <a><img/></a> It appears everywhere except posts and pages with existing comments.
    <?php endif; ?>
    You can see this text everywhere!

    There is a number of similar plugins for your taste, like Enhanced Text Widget.

    Another Helpful Plugin would be Widget Display Options

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘to hide a certain ad on pages with comments’ is closed to new replies.