Widget Logic
How do I use widget logic to link to more than one page? (17 posts)

  1. lizsaskia
    Posted 5 years ago #

    I am designing a website for someone who arranges work placements in the UK for Italian and Slovenian students, so I need my site to be available in all three languages. I have decided not to use translation software as the translations aren't very good, so am making 3 versions of each page.

    I have made 3 links using images of the three flags, and I want the home page to link them to the other versions of the home page and so on.

    I can get the image to show on each page individually using the codes:


    Is there a way to put all of these in the same widget logic box so I don't have to make 3 widgets for each page?


  2. alanft
    Plugin Author

    Posted 5 years ago #


    You want it so that the logic returns TRUE if A or B or C are true, so join them together with the logical 'OR' operator which is two bars:

    A || B || C

  3. lizsaskia
    Posted 5 years ago #


  4. nikcree
    Posted 5 years ago #

    I have tried (!is_page('1438') || !is_home()) to exclude widgets from the home page and page 1438, but the widgets still appear on these pages.

    If I do
    !is_page('1438') the widget does not display on page 1438 or,
    !is_home() the widget does not display on the home page.

    I have tried (!is_page('1438') || !is_home()) and !is_page('1438') || !is_home() and have the same problem of widgets still showing.

    What am I doing wrong?

  5. lizsaskia
    Posted 5 years ago #



    It seems to work with && rather than || and you don't need the brackets around it

  6. nikcree
    Posted 5 years ago #

    Thanks @lizsakia. I tried your suggestion and this does hide the widget from the front page but still not page 1438. I must admit to being a bit stumped about this.

    Oops my dyslexia got in the way. I changed the page number to 1483 and all is working! :)

  7. Piet Bos
    Posted 5 years ago #

    @lizsaskia - regarding your multi language problem, I would like to suggest you to use WPML (http://wpml.org). With this plugin you provide the translations yourself, but the plugin takes care of the whole language integration.

  8. lizsaskia
    Posted 5 years ago #

    Thanks Piet, that was the one I ended up using!

  9. hollowjack
    Posted 5 years ago #

    I want a widget to show up on

    1. All post pages EXCEPT its own post page ("/bff-miami")
    2. Its own category page ("/category/bike-miami") BUT no others
    3. All pages EXCEPT one specific page ("/events")

    What is the most concise way to do this in widget logic?

    So far I have this, but it doesn't keep the widget off other category pages.

    !is_single('bff-miami')&&!is_page(events )&&is_category('bike-miami')

  10. hollowjack
    Posted 5 years ago #

    SCratch that last question. I basically want to know why the following code isn't working.

    !is_single('podcast-9') || !is_page('events') || is_category('bike-miami')

    Right now the widget shows up everywhere.

  11. alanft
    Plugin Author

    Posted 5 years ago #

    Because every URL you look at will be either true for




    When on the podcast-9 post/page, it's True that it's not the events page and vice versa

  12. hollowjack
    Posted 5 years ago #

    So what would the code be if I DON"T want the widget to show up on the post 'podcast-9', DON"T want it to show up on page 'events', and DO want it to show up in the category 'bike-miami'?

    Very much appreciate your help. I've confused myself thoroughly at this point.

  13. lizsaskia
    Posted 5 years ago #

    Have you tried it with '&&' instead of '||'?

    !is_single('podcast-9') && !is_page('events') && is_category('bike-miami')

    That way it will only show up if all the conditions are true. You can also use the page number at the end of the URL instead of the keyword, and can use these in an array if you want to specify more than one page.

  14. kbellis
    Posted 5 years ago #


    This is not a hijacking... only a point of clarification; or moreover, in pursuit of one:

    Please, could some kind soul please provide a reference to a concise list and explanation of all operators, logical and otherwise, germane to WordPress ???

    From the posts above and from several others, I gather these to be correct - but please correct me:

    Logical Operators
    || means OR, like, either yes or no
    ! means NO, like, no way can I learn all of this stuff /* LoL */
    && means AND, like, this and that

    Then I tripped over something called Ternary Operators just as my eyes began glazing over...

    Thanks for any pointers!


  15. kbellis
    Posted 5 years ago #

  16. lizsaskia
    Posted 5 years ago #

  17. kbellis
    Posted 5 years ago #

    Thanks Liz, I very much appreciate it.

    I saw that codex page too - I think Alan linked to it - most helpful indeed... but didn't get much on operators from it. It seems that each little branch of code languages has there own take on things; e.g., like Pear or CC, but not quite.

    Am I correct in thinking that WordPress is entirely built on php and I'd be better off staying in that classroom rather than wondering lost in all of the school's hallways?

    Okay, so, with much thanks and appreciation to you, Alan and the others posting in this thread, I've been successful in utilizing Widget Logic (test site - my latest science experiment: http://panocea.us/wp-test2/ - Widget Logic is absolutely just the right solution for my needs.

    Using the conditional statements and logical operator: is_single( '451' ) || is_home() I was able to display the text widget's html content in two places only.

    Because the content in the widget is only on the home page for a while, an indeterminate period; day, month, whatever, the is_home() will be later removed from that particular widget. And then the next update in that widget's featured location will own that space; for example, is_single( '524' ) || is_home()

    The thing I worry about now, is the one widget container could end up with hundreds of discrete text widgets all with their own peculiar widget logic / conditional statements. Is that about the way it is? or is there some other nifty means of managing the plethora of conditional statements that could reside in a single container?

    The theme I using is Suffusion if that enters into the mix...

    Kind regards,


Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic