Title: Syntax Error with Widget Logic
Last modified: August 20, 2016

---

# Syntax Error with Widget Logic

 *  [lombardipublishingjoey](https://wordpress.org/support/users/lombardipublishingjoey/)
 * (@lombardipublishingjoey)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/)
 * Here’s the error:
 * [Tue May 08 09:07:08 2012] [error] [client 10.183.253.48] PHP Parse error: syntax
   error, unexpected ‘{‘ in /var/www/vhosts/XXX.com/wp-content/plugins/widget-logic/
   widget_logic.php(270) : eval()’d code on line 1
 * Any idea what the issue could be?
 * [http://wordpress.org/extend/plugins/widget-logic/](http://wordpress.org/extend/plugins/widget-logic/)

Viewing 8 replies - 1 through 8 (of 8 total)

 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2734981)
 * 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
 *  [CatGraphicsWeb](https://wordpress.org/support/users/catgraphicsweb/)
 * (@catgraphicsweb)
 * [14 years ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735264)
 * 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. Thanks.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [14 years ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735272)
 * You have one more ( than you have ), which is why you are getting a “PHP Parse
   error: syntax error”
 *  [CatGraphicsWeb](https://wordpress.org/support/users/catgraphicsweb/)
 * (@catgraphicsweb)
 * [14 years ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735274)
 * 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.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [14 years ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735275)
 * 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
 *  [CatGraphicsWeb](https://wordpress.org/support/users/catgraphicsweb/)
 * (@catgraphicsweb)
 * [14 years ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735276)
 * 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!
 *  [CatGraphicsWeb](https://wordpress.org/support/users/catgraphicsweb/)
 * (@catgraphicsweb)
 * [14 years ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735277)
 * 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](https://wordpress.org/support/users/blackangelsaveena/)
 * (@blackangelsaveena)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735372)
 * 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.

 * ![](https://s.w.org/plugins/geopattern-icon/widget-logic_c8dde5.svg)
 * [Widget Logic](https://wordpress.org/plugins/widget-logic/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/widget-logic/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/widget-logic/)
 * [Active Topics](https://wordpress.org/support/plugin/widget-logic/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/widget-logic/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/widget-logic/reviews/)

 * 8 replies
 * 4 participants
 * Last reply from: [Joshi Saveena](https://wordpress.org/support/users/blackangelsaveena/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/syntax-error-with-widget-logic/#post-2735372)
 * Status: not resolved