Title: Widget Logic &#8211; Just plain doesn&#8217;t work
Last modified: August 19, 2016

---

# Widget Logic – Just plain doesn’t work

 *  [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/)
 * Widget Logic just plain doesn’t work for my theme. I can tell you three basic
   things:
 * 1. The widget always is displayed on every page
    2. Setting logic to ‘false’ 
   doesn’t change anything 3. The default theme does work with widget logic
 * I saw this topic:
    [http://wordpress.org/support/topic/199255](http://wordpress.org/support/topic/199255)
 * I think we have the exact same cases.
 * So what exactly makes a theme widget logic compatible?

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/page/2/?output_format=md)

 *  Thread Starter [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921507)
 * Has anyone got any idea at all? I checked the default theme and the code that
   draws the dynamic sidebar appears to exactly the same as what I have.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921514)
 * what’s your theme?
 * short answer, if a theme messes around a lot with WP queries, the standard conditional
   tags (is_home etc) can fail. however if you’ve tried just false, and it still
   doesn’t work, that’s really odd. that should block the widget regardless.
 * unless you have some sort of aggressive caching going on.
 * tell me more
 *  Thread Starter [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921524)
 * Hi alanft,
 * The theme I’m using is built from a wordpress-ignorant design. So in terms of
   WordPress functionality, I made it.
 * The worst I mess around with WP queries is indeed in the sidebar. It’s just a
   simple code to show a rundown of stories from a particular category. If I take
   it out, though, it does not change a thing. Here’s the code from the sidebar.
   php:
 *     ```
       <td class="left_content">
       <?php
   
       if ( function_exists('dynamic_sidebar') ) {
            dynamic_sidebar();
       }
       ?>
   
       <?php if( is_home() ) {
   
       $postlist = get_posts('category_name=events&numberposts=5');
       foreach ($postlist as $post) {?>
       <div class="event-post">
       	<h2 class="event-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
       <span class="event-entry">
       	<?php the_excerpt(); ?>
       	<?php the_content("Read more &raquo;"); ?>
       </span>
       </div>
       <? } ?>
       <? } ?>
       </td>
       ```
   
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921543)
 * and that code is after the dynamic sidebar is called anyway – so it shouldn’t
   have any impact.
 * does the problem persist even with the default theme rather than your own?
 * edit:
 * oops i see you’ve already tried that and it is ok, so there is something up with
   your theme. do you have a large functions.php? otherwise i’m totally out of troubleshooting
   idead without getting hand on 🙁
 *  Thread Starter [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921546)
 * Thanks for following up 🙂
 * Theme functions file is pretty small. Here it is:
 *     ```
       <?php
       if ( function_exists('register_sidebar') )
           register_sidebar(array(
               'before_widget' => '<li id="%1$s" class="widget %2$s">',
               'after_widget' => '</li>',
               'before_title' => '<h2 class="widgettitle">',
               'after_title' => '</h2>',
           ));
   
       function exclude_category($query) {
       	if ( $query->is_home ) {
       		$query->set('cat', '-7');
       	}
       	return $query;
       }
   
       add_filter('pre_get_posts', 'exclude_category');
       ?>
       ```
   
 * I’ve removed that exclude_category function and that did nothing.
 *  Thread Starter [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921549)
 * The only other code that executes before this is in header.php. I gave this a
   look-see but nothing too interesting – just a bunch of bloginfo() calls.
 * Is there something that needs to be in functions.php that I don’t have?
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921557)
 * well i’m stumped.
 * you could try troubleshooting using an exec PHP widget – that way you can ececute
   some PHP like
 * if (is_home()) echo “THIS IS HOME”;
 * in a widget to see if is_home() is working ok, and so on. if you could parcel
   up your theme and make it available to download, i’ll see if it is the theme.(
   it really doesn’t look like it, from the code you give). you’re on 2.6, and i
   can setup a vanilla 2.6 wp here with your theme to play with
 *  Thread Starter [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921574)
 * So here’s the results:
 * 1. I installed PHP-Exec. The extension works fine. Widget Logic = 🙁
    2. Here’s
   the theme: [http://pk-fire.com/etc/spranklez.zip](http://pk-fire.com/etc/spranklez.zip)
 * Thanks so much again
 * EDIT: The site I’m working on is at:
    [http://spranklestudios.com/wp/](http://spranklestudios.com/wp/)
 *  Thread Starter [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921577)
 * Aha! It’s always the simplest of things, isn’t it?
 * Googling around, I found this topic:
    [http://wordpress.org/support/topic/197792](http://wordpress.org/support/topic/197792)
 * I saw that and simply thought, “Huh.”
 * I looked at the default theme. Sure enough, it makes a call to wp_head(). Right
   before the </head> tag.
 * My theme didn’t. 🙂
 * alanft, thanks so much for your help. And I just realized you’re the developer
   of Widget Logic – great plugin!
 * Also, I might add that this issue could be FAQ-worthy. 😉
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921581)
 * thank you! i will indeed add this to the faq.
 * i will have to look into how that makes a difference.
 *  Thread Starter [oneeyedparrot](https://wordpress.org/support/users/oneeyedparrot/)
 * (@oneeyedparrot)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921589)
 * I think that wp_head() triggers one of those critical hooks that WL depends on
   very dearly to work.
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [17 years, 5 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921603)
 * foolish me – it kicks off the all important hook in widget logic!
 * blushes all round!
 *  [suite22](https://wordpress.org/support/users/suite22/)
 * (@suite22)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921707)
 * Hi, 1st time using WordPress. I installed your plugin so that I can replace my
   widget headers with images. I’ve uploaded one graphic that I would like to replace
   on a widget. It can be viewed at [http://www.breemusic.com/images/learn.jpg](http://www.breemusic.com/images/learn.jpg)
   If you visit my site at [http://www.breemusic.com](http://www.breemusic.com) 
   I am trying to replace the text in the top left widget with that graphic. How
   can I do this with your plugin. I’ve read all documentation and I am still stuck.
 * Thanks
 *  [alanft](https://wordpress.org/support/users/alanft/)
 * (@alanft)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921708)
 * you don’t need WL to do this. you can do it in just CSS
 * there’s a part explanation here
 * [http://wordpress.org/support/topic/173940](http://wordpress.org/support/topic/173940)
 * (ignore kevinadams workround at the bottom – that’s a terrible way to do it).
   Basically what you need to do is add a bit of CSS in your theme that targets 
   your widget header like this:
 *     ```
       .widget_recent_comments h2 {
       text-indent: -9999px;
       background-image: url('imageurl.jpg');
       display: block;
       width: 100px;
       height: 100px;
       }
       ```
   
 * which targets a widget with class “widget_recent_comments” (look in the HTML 
   of your site to find out the class of the widget you want to target) and changes
   the heading part of that (the h2 sub-bit) so that the text is effectively hidden(
   indented out of sight) and the whole h2 chunk is definsed as a box of the specified
   size and background image
 * HTH
 *  [mtg169](https://wordpress.org/support/users/mtg169/)
 * (@mtg169)
 * [17 years, 1 month ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/#post-921710)
 * I am having a problem with widget logic working when I specify categories to 
   include in query_posts. I am using the is_home() conditional tag on a couple 
   of sidebar widgets. If I exclude categories in query_posts it works fine. I’d
   like to specify included categories only so that I do not have to change the 
   code every time I add a new category.
 * The following code works and widgets are only displayed on home page:
    `query_posts("
   cat=-1,-6,-11,-21,-23,-24,-27,-35,-38,-40&posts_per_page=1");`
 * If I use this code, the widgets with the is_home() conditional tags do not show
   on any page at all:
    `query_posts("cat=3,4,5,7&posts_per_page=1");`

Viewing 15 replies - 1 through 15 (of 21 total)

1 [2](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/page/2/?output_format=md)

The topic ‘Widget Logic – Just plain doesn’t work’ is closed to new replies.

 * 21 replies
 * 5 participants
 * Last reply from: [alanft](https://wordpress.org/support/users/alanft/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/widget-logic-just-plain-doesnt-work/page/2/#post-921750)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
