Support » Plugin: Widget Logic » How do you exclude a page from showing a widget?

  • What conditional tag should I use to exclude a page?

    I want a widget to appear on all my Pages except for the main blog Page which is……….. http://www.website.com/blog/

    The /blog post ID = 2358

    I don’t want the widget to show up on /blog page or any posts….eg. /blog/titleofarticle/

    When I use
    is_page(‘2358’) – widget only appears on /blog page however not on any pages or posts
    !is_page(‘2358’) – widget doesn’t appear on /blog……..however it appears on all Pages and my blog posts (e.g. /blog/titleofarticle/)

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Better way to exclude a page and sub-pages of certain page is to use Widget Content,
    which you can list certain page and sub-pages of certain page, where you want to exclude widget.
    If you set this way, certain widget doesn’t exist is blog page and sub-pages of blog pages:
    Target by URL:
    https:…/blog/
    https:…/blog/*

    Alternative you can create your own function as use it as a condition. Easiest this can be done by using Code Snippet plugin.

    function showInBlogPage(){
    $blog=stristr('https://' . $_SERVER['HTTP_HOST']. $_SERVER['REQUEST_URI'],'/your-site-name/blog'); 
    return $blog;
    }

    use this as condition:
    !showInBlogPage()

    So If I don’t want the widget to show up on the page… http://www.domain.com/blog………..or any of the blog posts…..e.g. http://www.domain.com/blog/bestbluewidget

    what would the conditional tag look like?

    is_page(‘https:…./blog/*’)

    No, is_page doesn’t support direct web-address.

    In my proposal !showInBlogPage() is the condition.

    My proposal !showInBlogPage() works, if blog page is not blog article page but other page. Blog articles has their own logic, where main page – sub-page system doesn’t exist.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do you exclude a page from showing a widget?’ is closed to new replies.