Support » Plugin: Widget Logic » Syntax Error with Widget Logic

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor alanft


    There’s something awry with some of your widget logic code where you have a stray or extra ‘{‘ bracket.

    export all your widget logic code to a config file for safe keeping and trawl through the widget logic in each widget looking for bad code – or just blank the code and see if that fixes it if it’s complicated. then you can restore it from the config file

    Hi, I’m getting the same error and maybe someone can help.
    I’m trying to prevent a default site-wide banner from showing up on specific category archives and single post pages by using this widget logic conditional tag:

    !is_category(array(X,XX) || !is_single() && in_category(array(X,XX))

    I have 2 other widgets that should take it’s place, and they do work – as long as the default site-wide banner widget is removed completely.
    Can anyone tell me if my above syntax is wrong?

    Looking at alanft’s response, I carefully checked all my sytax for any errant brackets but it looks ok. I’m a PHP newbie, so maybe the above code is wrong?
    Any help appreciated.

    Plugin Contributor alanft


    You have one more ( than you have ), which is why you are getting a “PHP Parse error: syntax error”

    Thanks alanft for the reply, I must be blind!
    I changed the code to this:
    !is_category(array(3,256)) || !is_single() && in_category(array(3,256))
    I added the missing ) after the first array.
    I think it works! Only reason I’m not yet convinced is because on 2 computers/5 browsers I have tested these pages so many times, both banner ads are showing up on the same page! I’m hoping this is only a browser cache issue on my local machines.
    If it works with additional testing – I’m thrilled with the help! I’ve been struggling with this all week. You’ve saved the day.. Thank you so much.

    Plugin Contributor alanft


    Great stuff.

    Based on your description of what you are trying to achieve you might want to try

    !is_category(array(3,256)) || !(is_single() && in_category(array(3,256)))

    and see if that improves things

    I think that may be better! You just added another set of brackets around the is_single statement. I tried it and it still works… I think I’ll put it on the live site and then I can really breathe a sign of relief!

    So after some more testing on the ‘test’ site, I finally bit the bullet and used the code on the ‘real’ site. But it did NOT work! It showed some wackiness with both banners overlapping each other. Even if my own browsers are showing cached material, viewers might have the same situation. I just don’t understand it. The test and real site are identical and in the same root, different folders. I copy/pasted the code from one to the other, so no chance of typos. I so want this !is_category..etc. to work as I might need it later. In the meantime I may have to use my fall-back plan to hard-code the default banner ad HTML into the header.php. “If/when” there’s a widget placed in the space with designated conditional tag, it should appear as it’s supposed to. Thanks for helping anyway!

    Joshi Saveena


    Hi all,
    I am a newbie here. I was having some wordpress issues for which i tried solving it by deactivating the plugins.I has a wysiwyg plug in with the widget logic already installed on it. So by degault, when i activated the plugins back my wigget logic for every post was gone. Its a whole bunch of posts and i dont know what logic is on which, so thinking if anyone could help me recover those widget logic codes back,, Need help seriouslyyy,,,, please…..

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Syntax Error with Widget Logic’ is closed to new replies.