WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
[resolved] Combining conditions (5 posts)

  1. HelenMoss
    Member
    Posted 1 year ago #

    Hi

    I have some widgets that I do NOT want to show on the blog page OR any of the single post pages (only on the pages I am using as part of my website, not as part of my blog). If I use this: !is_single() it works,
    If I write: !is_page('blog') that works
    But if I write this:
    !is_single() || !is_page('blog') nothing works.

    In short, it seems I am doing something wrong once I combine the conditions, they only work when there is one of them. Can anyone shed any light please? I've spent a couple of hours trying to figure it out already!

    Thanks so much!

    http://wordpress.org/extend/plugins/widget-logic/

  2. alanft
    Member
    Plugin Author

    Posted 1 year ago #

    you need to use && AND instead of || OR, because what you want to say is

    "show the widget (when it's NOT single) AND (when it's NOT page X)"

    if you put OR in there you'll always get the widget except when it's single and page X

  3. HelenMoss
    Member
    Posted 1 year ago #

    Thanks for your quick reply.

    I tried your solution and with
    !is_single() && !is_page('blog')
    the widget is hidden on the single post pages but not on the main blog page. On that blog page it is still showing and I don't want it to show there. I only want it on the other pages (which are my website, rather than my blog).

    Can you explain why?

    Thank you very much!

  4. alanft
    Member
    Plugin Author

    Posted 1 year ago #

    sorry - I missed it was your main blog page. the is_page('blog') probably wouldn't work then. You'll likely need is_home() or is_front_page() depending on how you've got your site setup. Seeā€¦

    http://codex.wordpress.org/Conditional_Tags#The_Main_Page

  5. HelenMoss
    Member
    Posted 1 year ago #

    Thanks for your reply, !is_home() worked!

    It doesn't make a lot of sense to me, maybe I'm not logical enough to understand widget logic! lol! No matter, the most important thing is that I can achieve what I want to, so thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic