Freaky Trigger’s WordPress Setup
Widget Logic
FT had a complex sidebar, but I decided to ‘widgetise’ it when Steve updated the theme in early 2008. To keep some of the special widgets appearing only when needed, I wrote a plugin to extend the functionality of widgets. Widget Logic allows widgets to appear or not depending on standard WP conditional tags, such as is_home() and is_single() and so on.
If you want to contact me about it you should address yourself to the WordPress org directory and perhaps post on the forum there. Or you can leave a comment here, below. PLEASE READ THE FAQ AND OTHER NOTES in the WordPress plugin directory first though.
If you find Widget Logic useful to you, then you could consider a small donation to Cancer Research UK – click ‘Donate’ on the widget over to the right there –>
VIDEO TUTORIAL! Popup or view on YouTube a screencast by Daryl Lozupone. Thanks to him.
Podcast Channels
Podcast Channels is a plugin that augments WP’s RSS feed with some extra elements, mostly in the ‘itunes’ namespace. It works with existing features of WP (auto-enclosures and the media library) to make a simple way to podcast, and allows different metadata in different RSS feeds – you can have as many channels as there are categories, tags, even blog authors.
Like a lot of people I found PodPress increasingly frustrating to use around WP2.6. I still see lots of people using it, but I found it was interfering with too many aspects of WP – wysiwyg editing, the media library, and so on. But there were only two things it did that I liked – show download stats, and allow multiple podcasts on a blog with their own rss and iTunes metadata. So i wrote a couple of plugins to target just those functions.
(I may release the stats plugin some day, but it’s nothing special, a bit clunky, and I really don’t want to support it.)
Freaky Trigger Theme
This was designed by Steve Mannion @ ghostfood.tv
Hi Steve. Widget Logic looks like a really nice plugin, Will there be an update for WP 2.5? It seems I get an error (in firebug), and no input fieds in my widgets.
Hi, I am trying to get a 2.5 version working. A bit of me thinks it might not be worth it, as 2.5 allows you to define many more sidebars and configure them in an elegant interface.
BUT to keep FT going and get us on to 2.5 I will get it working asap. (we’re on a patched version of 2.3)
however until podPress updates to working ok with 2.5 i’m not exactly hurrying.
Just another person chiming in, hoping for a 2.5 compatible update to widget logic. It’s a great plugin…
Hey, i’m another one. I hope the widget logic works with wordpress 2.5 version. Please. Is a great pluggin.
The features of WordPress 2.5 sidebars never will be good than the excelent Widget Logic features.
And you have the only one plugin that can do this, i been searching and i don’t find anything like widget logic.
if you check the official site http://wordpress.org/extend/plugins/widget-logic/ you’ll see i did update the code to be 2.5 compatible
Hi there FT, I am wondering what kinda plug-in do you use to get those great highlights in top of your webpage? (europop, poptimism, slugs on the radio) Let me know! :)
the 3 lozenges at the top (europop, poptimims and slugs) don’t highlight tho? they’re just 3 DIVs in the HTML with an onclick:
<div id=’head_europop’ onclick=”location.href=’/europop2008/'” title=”Europop 2008″>16 nations, your votes, EXPECT EMO</div>
and the position and appearance are set in CSS. the HTML (defined in our themes header.php file) and the CSS (in the theme’s style.css file) are tailor made for FT – no plugin. sorry.
Tnx for your fast reply. so it’s just html/css… not dynamic?
what is there that you think IS dynamic? the images don’t change. there’s not even a simple roll-over effect on those items.
the category bar (music/tv/games etc) and the functions (random/login etc) now those have some dynamicness that’s done with JS. but again no plugin – custom made code to fit with the theme design.
hi. Thanks for plugin
perfect.
regards
can you help me out with a little logic ;-)
I want a certain widget to be only displayed if its not on a certain page, something like is_not_page(‘551’) but I do not know how to write that condition :-(
!is_page(‘551’)
i think should do it
thx that worked.
now I have a compatibility problem.
I have 2 sidebars, with both showing on the homepage but only one on all other pages. So I need to use your plugin, to make 2 widgets from sidebar 1 to disappear on the homepage and appear on sidebar 2.
I tried !is_home() for both widgets, but as soon as I save,both conditions disappear. It seems to work fine if I only use this condition on one widget, but as soon as I use this condition ob two widgets, liek I said, the conditions both disappear…
any clue what could be wrong? did you test your plugin in a similar situation?
can you try and use !is_home() on two widgets, and the nsave and see if that works for you?
(in case you check back, i did reply on the wordpress org forums for you. sorry our server went wobbly when you posted that)
Hello, I just wanted to thank you for this plugin. I was at my wits’ end trying to wrangle different sidebars for different parts of my site into order, and this has made everything work like a dream!
Hi,
thank you so much for this incredible plugin!
I’d like to use it on my website but i have a problem: when i activate the plugin i receive some errors instead the sidebar like this:
Warning: Illegal offset type in /web/htdocs/www.nomesito.com/home/wp-content/plugins/widget_logic.php on line 126
reporting errors in line 126 and 129.
Do you have idea why it happens?
Thank you!
Looks like you are using a widget that doesn’t play by what i think the rules of widgets are! What widget plugins are you using?
You could also try deactivating each of the widget plugins in turn to see if the problem goes away, then let me know which one causes the problem, and i’ll see what i can do to code around it.
Hi Alan,
thanks for your plugin. I want to use it because of the ttftitle thing, but I don’t know how to use it in this case. What code I have to add in my function.php or elsewhere to display the images?
There’s code on the other notes page of the plugin page on wordpress.org
use that code, along with an add_filter like it explains, in your themes functions.php and that should do you.
Hello
I would love to download your Widget and could you email me the download do you have to pay for it? do you have a 30day free trial?I do not have any assets right now and I am brand new at blogs and I would love more information on your Widget. Thank You for creating this-I sure would love to try it out.
Thank You Brent & Jeannie
Follow the WordPress org directory link in the post above – they host the download.
I’m getting the same warning that Fil did above:
Warning: Illegal offset type in /home/ioventur/public_html/wp-content/plugins/widget-logic/widget_logic.php on line 126
Warning: Illegal offset type in /home/ioventur/public_html/wp-content/plugins/widget-logic/widget_logic.php on line 129
I deactivated all widget plugins and it didn’t fix it but it did work once I changed my WP theme. The them that I was using was semiologic.
Not sure exactly what the issue is with semiologic and your plugin.
Thanks for any feedback.
I just tried out the semiologic theme (from here and it doesn’t work with WP2.5 very well even without widget logic – when you edit widgets it comes back with messy intermediate pages instead of the proper admin interface. Is there a 2.5 update?
having said that i activated widget logic and i didn’t get your error right away, so it’s not as simple as Wp2.5 + SL theme + WL plugin = error. :-/ any more info gratefully received.
theSL theme is quite complex and does do a lot of custom things to widgets: killing off WP’s built in widgets! and adding a ‘context’ option – a bit like what WL tries to do, and in a similar manner, but in a pre-2.5 manner.
TRY THIS THOUGH:
Look in semiologic/admin/widgets.php file, find “add_action(‘init’, ‘sem_widget_controls_init’);” and comment it out with a “#” at the start of the line. It looks like this deactivates semilogic theme’s “widget context” controls and stops clashing with widget-logic.
It might disable other things – i just don’t have the time to check. But let me know how you get on.
Very useful information. Thanks!!
great plug in ideas Alan! I’m always looking for ways to facilitate networking with like-minded individuals. I especially appreciate unique tools that help me harness the power of web 2.0 and social bookmarking sites so I can make good use of my time. There’s nothing worse than spending countless hours online to build your online presence, while losing valuable time that you could be spending with your friends and family. Luckily, I’ve found tons of useful tools to meet like-minded individuals and network super efficiently. In this age of user generated content driving up a website’s ranking, content is king and getting that content in front of the right people is the name of the game! Keep up the great blog.
—
Ana Hernandez, CEO Netrageouz.net
http://www.netrageouz.net/toolbox.htm
Hi,
great plug-in! Can you help me?
I try to hide the Categories Widget just from one page (id172)and show it on all other pages of the website.
What is the code?
Thanks !
look at the examples on http://wordpress.org/extend/plugins/widget-logic/other_notes/
I was wondering how to get a widget to appear on multiple pages by indicating which specific page id’s i want the widget to appear on. how is this done?
This is a great plug in :)
@ hershal
you could use PHP’s logical OR operators like this
is_page(‘about-me’) || is_page(’42’) || is_page(‘About Me And Joe’)
or if you read http://codex.wordpress.org/Conditional_Tags you’ll see you can do the slightly more PHP-savvy but simpler
is_page(array(42,’about-me’,’About Me And Joe’))
This is one of the most useful plugins installed on my blogs. :-D
I have just one question:
How can I exclude just one page and show the widget on all other pages (home, single, page)?
I have looked at the examples on the suggested WP site, but still don’t have a clue what code to add to the widget logic box.
Can you please help me out?
Greetz!
Mieke
add a ! on the front, which means NOT in PHP
!is_home()
etc. i will add this to the plugins FAQ on the wordpress plugins site
Alan,
Love the widget Logic plug-in. Quick question though. I have been having problems with the speed of my site. I want to blame the host, they want to blame my plug-ins (I did go crazy with plug-ins when I started building my site). Since my site is so dynamic, at least the sidebar, I really can’t use a cache, or at least I don’t know how to use it with my sidebar and your plug-in.
So 2 questions:
1. Do conditional tags slow down the page loading by making additional calls to the database, or are conditional tags just reading the data que from the last query?
2. Do you no of a way to be able to use your plug-in and WP Cache. WP Super Cache I don’t believe will help me since most of my users log in when they visit.
thanks.
1 – i don’t believe so, no. if you look in wp-includes/query.php you’ll see a lot of the conditional tags code there. and they all do fairly simple manipulations of already established query results. is_home for instance is just
global $wp_query; return $wp_query->is_home;
and so on
2 – the plugin doesn’t have any problem working with wp cache. unless you are using conditional tags that will produce different results over time.
This looks like a fantastic plugin, can’t wait to try it out. It looks a bit like Ozh who sees ads, but your plugin seems more easy to use.
Thanks a bunch.
Hi there, is there a way to make a text/html widget on my blog appear only to me (as an admin) or to (logged in users) using this plugin?
You can use the current_user_can(‘capability’) function, like this guy did:
http://wordpress.org/support/topic/179656?replies=5
Is this working on 2.7? I keep getting an error when I update anything site wide.
Warning: Cannot modify header information – headers already sent by (output started at /home/gvegason/public_html/krah/wp-content/themes/fresh-editorial/functions.php:15) in /home/gvegason/public_html/krah/wp-includes/pluggable.php on line 850
it’s working on my 2.7 install yes. what happens when you switch to the standard theme? as it looks like something in the functions.php of your “fresh-editorial” theme is where the problem starts
This is exactly what I was looking for, but am having some slight issues. If I do is_category(‘fun’) the widget shows up when visiting page http://mydomain/category/fun/ but doesn’t show up on post in the category with urls http://mydomain/fun/post1
Please help.
Thanks,
Eric
you want to use is_category for category pages and in_category for posts that are in specified categories
the pages at WP, specifically http://codex.wordpress.org/Conditional_Tags are very useful on points like this
Thanks for your reply! I should have done a little more research before asking.
Hi-Thanks for all the useful information and the plugin–Andy
Hi Alan,
I’m trying to get this to work with TTFTitles, but I keep getting errors. Since I’m still pretty much a n00b at php, could you help me out? I copied and pasted the codes (add_filter and the function) in my theme’s functions.php file, but I keep getting ‘unexpected’ errors. Here’s my code:
add_filter('the_ttftext', 'ttftext_widget_title', [priority], 2);
function ttftext_widget_title($content='', $widget_id='')
{ preg_match("/]*>([^<]+)/",$content, $matches))
$heading=$matches[1];
$insert_img=the_ttftext( $heading, false );
$content=preg_replace("/(]*>)[^<]+/","$1$insert_img",$content,1);
return $content;
}
Thanks in advance :)
Oh never mind, I fixed it myself :) There seemed to be an error in the filter for ttftitles, here’s the fixed version:
function ttftext_widget_title($content='', $widget_id='')
{ preg_match("/]*>([^<]+)/",$content, $matches);
$heading=$matches[1];
$insert_img=the_ttftext( $heading, false );
$content=preg_replace("/(]*>)[^<]+/","$1$insert_img",$content,1);
return $content;
}
$matches was closed with )) instead of );
One more thing though: what is meant with [priority]? I removed it to get rid of the “unexpected ‘]'” error.
oops! i hadn’t noticed that extra ) in the TTFcode before – it should be a semi-colon instead. (which is otherwise missing!)
[priority] is the optional parameter that you can give when you register with add_filter – it allows you to set order of filtering routines if needed.
http://codex.wordpress.org/Function_Reference/add_filter
thanks for pointing both these out – i will try to remember to update the official WP repository
Okay thanks! :)
This is such a great plugin. I thought I would have to code a whole new sidebar for every page other than my index page and this theme has solved my problems effortlessly. Your work on this plugin is greatly appreciated at ilapko.com. Thanks!
:-)
remember you can still define different sidebars to be invoked by different template files (home.php, single.php. etc)
I’m trying to figure out the right widget logic to use to display a widget only on a page or a sub-page of that page. I took a look at WP’s conditional tag information, and figured it is some variation upon
( is_page(‘title’) || $post->post_parent == ‘xx’ )
But nothing I try seems to work. Any tips?
see my post here
http://wordpress.org/support/topic/207694
Thank you, Alan! Awesome plugin and awesome help!
Little annoyance: whenever I make changes to my widgets and save it, the Widget-Logic switch turns off and I need to click the Save button again for it to work… Is there a fix for this so that it stays on?
Thanks :)
“the Widget-Logic switch turns off” – do you meant the ‘widget_content’ filter option? if so are you sure you have an up-to-date version – that happened on an early version, but i’m pretty sure i fixed it.
also – do you use the filter anyway? you don’t need that option ticked for ordinary widget logic options to work. it’s used to manipulate the content of widgets with special PHP code.
I do use the filter for ttftitles; without the filter on it just displays normal text. And I’m using the latest version… (0.43)
:-) ok just checking. surprised that the tick box is blanking as i thought that had been dealt with in a much earlier bug fix. will check on that for you.
it’s about time i had an offical update – the ‘2.7’ compatibility update i did needs flagging up properly.
update:
i can’t get the tick box to blank if i change a widget in WP 2.5/2.6 or 2.7. it might be that i’m on a development version that already tackled this issue. see if using that (download at http://wordpress.org/extend/plugins/widget-logic/download/) improves things for you.
otherwise we’ll need to troubleshoot – go to the WP forums and post here http://wordpress.org/tags/widget-logic so we’ll go through it. things like deactivating plugins to see if there is another plugin out there that’s clashing with WL
FURTHER UPDATE
there is a fix for this in the development version. i will be updating it into a full release soon – mostly to update the documentation.
Just updated, works fine now!
I freaking love you for writing this plugin! You have made my day!! Thank you!
Firstly, thanks so much for this plugin – it’s the answer to my prayers :)
Thing is, I’ve found myself in a bit of a mess and I’m not sure how to fix it.
What i wanted to do was to include a widget on all pages except two. I managed to exclude one page – using !is_page(’page-name’)- no problems, but wasn’t sure about how to exclude two pages at the same time.
I decided to try a few things, starting with !is_page(’page-name’)||is_page(‘other-page-name) but immediately got an error message. I tried to undo it but everytime I tried to save a change or even delete a widget completely I got this message.
Warning: array_keys() [function.array-keys]: The first argument should be an array in …./wp-content/plugins/widget-logic/widget_logic.php on line 29
Warning: Invalid argument supplied for foreach()… /www/wp-content/plugins/widget-logic/widget_logic.php on line 29
Warning: Cannot modify header information – headers already sent by (output started at …./wp-content/plugins/widget-logic/widget_logic.php:29) in …..www/wp-includes/pluggable.php on line 850
I’ve tried deactivating and resinstalling the plugin but the problem persists even after a fresh install – ie can’t save any changes to any wiget without the error message. Also when i open a widget for editing the widget logic box always contains a single character (like ?, C. or I) in it which but i try to delete always comes back.
The only thing that fixes the problems is deactivating the plugin altogether, which I really don’t want to have to do cause it will be such a life saver if I can get it working!
Any ideas on what may be going wrong or how to fix this would be massively appreciated :)
Thanks!
Matteo
odd one. sounds like the WL options have got corrupt. try going to wp-admin/options.php in your setup and seeing if you can clear the ‘widget_logic’ field. if it says ‘serialized data’ you can’t clear it this way. you could clear it with a direct change in your database
or you could hack (improve!) the widget logic code like this… Change line 18 from:
if(!$wl_options = get_option(‘widget_logic’)) $wl_options = array();
to
if(!$wl_options = get_option(‘widget_logic’) || ! is_array($wl_options)) $wl_options = array();
which should reset your preferences to all empty again.
the code you need to exclude two pages will be
!is_page(array(‘page-name’,’other-page-name’))
HTH, Alan
Hi Alan, thanks very much for helping out.
I couldn’t locate a ‘widget_logic’ field in options.php so I tried making the other change you suggested. I replaced the code at line 18 but no joy. I then noticed that the same line of code appears again further on in the file so i tried replacing that as well. Don’t know if that was a good idea or not but it had the effect of eliminating those characters that kept appearing in the widget logic box.
So I got somewher, but there’s still no luck with trying to save changes or implement new code. I keep getting the same error. It’s frustrating cause it was all working fine initially, so I just need to be able to start again from the beginning somehow. One other thing, after trying to save any widget changes the site front end also throws up the following error messages anywhere where a widget should be located.
Warning: Unexpected character in input: ‘ in …..www/wp-content/plugins/widget-logic/widget_logic.php(132) : eval()’d code on line 1
Parse error: syntax error, unexpected ‘)’ in …/www/wp-content/plugins/widget-logic/widget_logic.php(132) : eval()’d code on line 1
Don’t know if that helps shed any light.
Thanks again for your help.
Matteo
you are right – that correction needs making in 2 more places i think to make it clean.
the new “unexpected ‘)’” etc errors are likely due to mistakes in widget logic code you are now trying in the widget interface. check all your widgets (on all your sidebars if you have more than 1) for widget logic code and check their syntax. somewhere there is a stray bracket or something like that.
Ok, things are loooking up :)
I couldn’t find any stray brackets and was on the verge of giving up in despair, but I decided to see if a fresh install of the plugin would work now that the bad data seemed to have been cleared. It did help!
Now there are no error messages when saving and I’ve been able to exclude single pages but when i try
!is_page(array(’page-name’,’other-page-name’))
this appears in the sidebar
Parse error: syntax error, unexpected $end in /usr/home/seobcn/www/wp-content/plugins/widget-logic/widget_logic.php(132) : eval()’d code on line 1
Is there any thing else I can do? Or any other code i can try which will produce the desired effect?
Thanks Alan!
Matteo
are you perhaps copying that code from here and that includes the curly quotes? if so, replace with simple straight quotes.
That was it! Thanks so much for all your help :)
Matteo
I like this plugin however I’m having problem how can I exclude one page? I mean I want the widget to appear on every post or pages except my about page. Any ideas?
Thanks in advance.
see comments 11-12 above
there are more examples and explanations on
http://wordpress.org/extend/plugins/widget-logic/other_notes/
I tried to put !is_page(‘about’) on one widget logic to exclude that widget on my about page but I’m getting this error:
Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/erikawor/public_html/wp-content/plugins/widget_logic.php on line 29
Warning: Invalid argument supplied for foreach() in /home/erikawor/public_html/wp-content/plugins/widget_logic.php on line 29
Warning: Cannot modify header information – headers already sent by (output started at /home/erikawor/public_html/wp-content/plugins/widget_logic.php:29) in /home/erikawor/public_html/wp-includes/pluggable.php on line 850
Please let me know what to do. Thank you again.
ok, that is a new issue that i think is the same as matteo’s above (see comments 59-62). no idea where its coming from, but it needs a proper fix – so i need to put this in the code permanently. You can try the quick fix suggested above, or wait for the plugin update. prob get that out by the end of the week.
emirie, i have updated the ‘development version’ on the WP site, which will be available to download shortly here. (it should say it’s v 0.45 at the top of the main php file if you need to check)
your problem should be dealt with by those fixes. let me know how it works out, and if all is well. i will do another minor official update.
Its works very well now and the widget shows the way I wanted to. As of now I don’t have any error or problems.
Thank you very much.
Terrific! and thank you for checking back and letting me know. i will release it officially over the weekend.
Hi Allan,
very nice and helpful plug!
I’ll have a couple of question on this plugin,not really
an assistance request.
A- would this ‘work’ to call inside my WP
the SSI of my */forum? (recente comment,or else)
B- would be possible to set More than 1 page in
the Widget Logic dedicated field?
Thanks for sharing your work and knowledge .
ciao
sorry Lorenzo, i’m not really clear on what you are asking in ‘A’.
In ‘B’ i take it that you are asking if it can make widgets appear in multiple pages, and yes it can, by using OR which is written ||
is_page(‘about’) || is_page(‘credits’)
would make a widget appear on both those pages
Many thanks,
and sorry for my bad english
the A: question was about the ability of your plug
to call within WP some SSI declarations
Those SSI are about a SMF located in the domain subdomain (while WP is ‘root’)
I’m Asking it because I’ve already tied out a different plug but I do find it a bit too pervasive.
MAny many thanks again.
lorenzo
no worries, not your english i suspect. i just don’t know what an SSI declaration is, or what an SMF is either :-(
Oh, I see, well it’s with great pleasure that I’ll intoduce
you to http://httpd.apache.org/docs/1.3/howto/ssi.html
and http://www.simplemachines.org
sharing knowledge, a lot less than what you already do :)
Thanks
Nice idea but it’s kinda buggy.
Like moving a widget higher up in the sidebar and suddenly it is no longer visible on the page.
that’s not something i’ve ever noticed happening with widget logic. if you could describe the problem step-by-step i’ll check to see if it’s my plugin or WP code that’s at fault.
back to lorenzo. Server Side Includes! i haven’t thought about those in a while!
ok, so “would this ‘work’ to call inside my WP the SSI of my */forum?”
no i don’t think there’s anything relevant to SSI usage in my plugin. However within WP as a whole as it’s PHP, there’s more than enough functionality there to pull in includes like the very basic SSI functionality of apache.
Hi,
The Widget logic code !is_page(‘some-page’) works fine while the code is_home() does NOT do anything??
I want to turn off a widget on only the Home page. I presume this is the way to do that..?!
The Widget content filter is checked and I use WP 2.7.1.
you don’t need the widget_content filter ticked – that doesn’t effect the widget logic fields or whether widgets appear on this or that page.
have you read http://codex.wordpress.org/Conditional_Tags#The_Main_Page and particularly the difference between is_home() and is_front_page() ?
Un-ticking the widget_content filter makes all widget logic fields go away. So I leave it ticked.
I did read this help file but it is written for technical people. I have a static page as the home page and I want to know what to use in the logic fields to set a sidebar widget only to display ont the static home page.
I tried these:
is_home(), is_front_page() and is_page(‘home’). None of them works..
Thnx in advance :)
“Un-ticking the widget_content filter makes all widget logic fields go away”
OMG YOU ARE RIGHT. this appears to be a really long standing bug i reckon. However it is just when you change that option. if you reload the widget page, the fields re-appear intact. i will attend to this v soon. i can’t believe this has only just been brought to my attention now – i’ve only just done a little update :-(
but thanks still!
meanwhile your separate issue…
try disabling any cache features you have. any difference?
try switching to the WP default theme. any difference?
The default theme does seems to be ok with the widget logic code is_front_page() . How can I make it work for my site?
I do not know much about the WP (and php coding). I have read something about the code wp_head() somewhere(?) but I do not know what to do with it exactly..?
I am using this theme (http://neewee.com/wordpress/mumrik-wordpress-theme/) for my website.
PS. Your server seems to be very slow (many 503 errors).
I am also using a different theme – Stars (http://www.premiumwp.com/the-stars-a-free-premium-wordpress-theme/) and am having widget logic errors.
Warning: Illegal offset type in /home/katchoo/dev/wp-content/plugins/widget-logic/widget_logic.php on line 125
Warning: Illegal offset type in /home/katchoo/dev/wp-content/plugins/widget-logic/widget_logic.php on line 128
Warning: Illegal offset type in /home/katchoo/dev/wp-content/plugins/widget-logic/widget_logic.php on line 125
Warning: Illegal offset type in /home/katchoo/dev/wp-content/plugins/widget-logic/widget_logic.php on line 128
Here is my dev site:http://dev.gamingangels.com/
I’ve tried searching the web and wordpress forum to see if anyone has the same problem, but no one has yet. I did start a forum on WordPress but I’d love to get your opinion on what I can do next.
Thank you for your time!
Trina
And we’re back. steven, trina, i’ll have a look at those themes. trina – i already noticed your post on WP forums and asked for a link to the theme you are using. which i see here. cheers. will let you both know what i find
trina – i have answered more fully on the wp forum with suggested fixes (the problem is that wp_head() is called twice in the theme)
steven – the sidebar.php code in your theme calls dynamic_sidebar (which is to say it outputs the widgets) after a special ‘query_posts’ command, which resets all the values of is_home etc based on that query.
the code says that query runs only if you have a selected “mumrik_featured_category_id”. (it looks like you can unset it by choosing the top “Select Category for Featured Articles” item from a drop down somewhere)
Someone has a similar issue before and they found that adding a `wp_reset_query();` fixed it. so have a go at putting that in before the sidebar is called on line 41.
Hi Alan
Thanks for the plugin! I downloaded it so I could use it with TTFTitles, but i need a bit of help. This is likely a stupid question, but that should make it an easy answer!
i’ve activated the plugin and added the filter and function codes to my function.php, but I’m uncertain about my next step. Is there something I need to put in the widget logic field to utilize TTFTitles for my widget titles? If so, can you tell me what the PHP code is?
I don’t know if this makes a difference, but i’ve added a second style to TTF to use as font for my sidebar titles. So it won’t be the default font that i use with WL.
Thank you!
so go through this checklist:
1 tick the ‘widget_content’ option on the widget admin page
2 register a new function to go on that filter using add_filter(‘widget_content’, … etc
3 supply the function for the filter (that uses the_ttftext function)
that should do it. the suggested code on the WP plugin page to do widget titles uses the_ttftext( $heading, false ); which should render the text in the default style you have configured in TTFTitles setup.
Thanks Alan
I’d already done steps 1-3 as suggested on the plugin page and the sidebar/widget titles weren’t impacted, so i thought there must be another step involved. Like putting something in the empty WL field.
is there a way to use a statement similar to the one below, that looks at all ancestors, not just the immediate parent? i have a multiple level site structure.
global $post; return ($post->post_parent==”31″);
great plugin btw
according to http://wordpress.org/support/topic/227954 you might try
global $post; return (in_array(31, get_post_ancestors($post)));
Great, thanks Alan.
I did have a good look around, but missed that thread.
works perfectly…
Yay, now I can really use WordPress as a CMS, awesome, thanks heaps!
Today the WP repository recorded the 10,000th download of Widget Logic.
:-)
Now, I’ve always been meaning to ask people – how could I make a simple interface instead of (as well as) the generic ‘write PHP code’ approach
I’m sorry but I’m still having problems with this module. While I don’t get the errors above anymore, the widget logic does not appear to be working.
I have checked the ‘use widget-content filter’ and on the widgets in the side I tried any conditional statement like is_home() and the widgets still appear in all the sidebars.
I guess it’s the Stars theme, but do you have any ideas of what I should look for?
looks like you saw comment 88, as you have responded on the WP forum?
if you’ve done that fix and it’s still not right, try the other suggestion i made in the wp thread which is to edit the theme’s header.php
I am not getting those header errors anymore. It just seems the widget logic conditions that I pass are being completely ignored. Where would I find that in the code?
I’m trying to use widget logic with the flexi pages widget to have two different menus I can use on specific pages but I can’t figure out (have looked at your other answers and wp conditional tags info) how to combine a command like this example: is_page(‘home’;’about’; ‘biography’; ‘ect’) to make those pages show up for that menu.
what is the correct syntax for listing multiple pages?
Grateful for any help.
sorry Trina – if the corrected head.php doesn’t fix it, and it is the theme to blame (did you say the problem goes away in the default theme?) then i really don’t know where to go next. i might try a test install of that theme and try it myself. not today though.
marilu – http://codex.wordpress.org/Conditional_Tags is an essential guide to the syntax of most logic you need. and you will find what you want under the bit on PAGEs.
I’ll try and look up more information but where in the process does it look to see if there is a variable set in widget_logic? Is it in sidebar.php? Or a file before that? That way I can see if the function is ever called.
I tried to use is_user_logged_in(‘false’) to show a newsletter subscription widget only if users are not logged in. That means “show this widget if user is a guest (not logged in).
both
is_user_logged_in(‘false’)
is_user_logged_in(‘true’)
display the widget only if the user is logged in, and I want it to be if the user is not logged in.
I was thinking about validate_username(‘false’) …
Since this is one of my few attempts to use any kind of functions, I could likely be doing something boneheaded!
PS: Definitely a cool and useful plugin!
it’s just is_user_logged_in() and doesn’t take any values
as usual in PHP to get the reverse you put ! at the beginning to add a logical NOT to the code:
!is_user_logged_in()
Awesome admin! How cool! Sending you a big smile from Vienna. Now I’m off to figure out how I can add a “widget” to the top part of my home page, in the “content” area and not the side bar.
Can I send you a buck or two via PayPal?
Best,
Dainis
I confirmed !is_user_logged_in()
Thank you for this topic
Love the plugin, but it seems it has a little bug, see more here: http://themehybrid.com/support/topic/hybrid-051-bug-report#post-19441
well i can’t view all that post as i’m not signed up for that site. if someone posts a description of the issue on the wordpress widget-logic tag forum i’ll see what i can do.
Now I’ve done that.
Sorry I forgot that you have to be logged in to see what Justin writes.
Basically it’s just when I use widget logic to display a widget on only 1 category page, then the rest of the pages shouldn’t display anything (and they don’t), but the page should also be in full width, and this isn’t the case.
According to Justin: “It’s because the plugin doesn’t “deactivate” the widgets while on that page. They’re still being read as active by WordPress.”
I have wanted to set up some Podcasts – so great information, thank you.
Works fine on my site with WP 2.71 French version. I use it to have the Video-Widget sidebar widget display a random video in the sidebar only when on the front of the site, using the conditional tag is_front_page().
Merci beaucoup!
Seems to work OK with 2.7.1, but gives an error when activating, and when saving the logic for a widget. It does install, and does save the logic though, so if you only intend to use it once when setting up your widgets, it does the job nicely.
any more info on those errors, i’ll investigate – tho it would be great if you could see if it was theme specific or if it’s still there when all your other plugins are off
Vielen Dank für diese guten Informationen,
mein Englicsch ist zwar nicht so gut, aber es hat gelangt
Mike
Hi,
I have added this widget to my site, (great widget) However I require my visitors to log into the website via google friend connect. The widget then seems to not realise that they are logged in even though wordpress does. I have tried it with just the single page function and it works great so I knwo the plugin works , plus when I log in as administrator it works fine but when I test it as a google friend it still appears using !is_user_logged_in()
be great if someone could shed some light :)
i don’t know a great deal about google friend connect, but a quick look around the net makes me think that if you have logged into it, that this is entirely separate to the wordpress login mechanism. so is_user_logged_in() isn’t going to be at all relevant to being logged in via GFC.
but sadly, i don’t know what mechanism you COULD use to identify people logged in via GFC. it looks entirely javascript driven and ‘client side’ – so the server won’t be able to tell.
sorry – if anyone can shed light on this, i’d be grateful.
Widget Logic is broken – or at least a ton of us are having issues with it. With 2.7.1 2.7 and on 2.8. Please help us out here. They keep dissapearing after adding the widget logic.
http://wordpress.org/support/topic/278187?replies=3#post-1098929
there is a problem with WL and 2.8, which I think i’ve already solved. will be updating the WP repository soon.
UPDATE: the Development version here will shortly be my first attempt at a 2.8 version (with some extra fixes thrown in).
I don’t think there are any general problems with WL and WP2.7 – though there are theme-code-related issues and one specific GUI issue. hoping to address some of these in the 2.8 version coming soon…
I have been trying to use Widget Logic to use the TTF Titles plug in for my Widget titles. The function code for the ttftitles returns tons of errors. The most common one is an “unexpected $end error” I don’t know if I am not doing it right or what. I copied and pasted this code:
function ttftext_widget_title($content=”, $widget_id=”)
{ preg_match(“/]*>([^<]+)/”,$content, $matches);
$heading=$matches[1];
$insert_img=the_ttftext( $heading, false );
$content=preg_replace(“/(]*>)[^<]+/”,”$1$insert_img”,$content,1);
return $content;
}
I am no PHP expert so is there any way you can give details on what to do with it and what changes to what and what closes it, etc? Thank you!
as you’ve taken this to the wordpress forums, i’ve answered there too.
Awesome, thank you so much. :)
Hiya, what a wonderful tool this is! Thanks a bunch. Now I’m trying to do the following:
Don’t show if user is not logged in and don’t show if user is not logged in and at this particular page
These are the pieces:
!is_user_logged_in()
!is_page(‘recently-acquired-tinnitus-survival-ecourse’)
But I don’t know how to make the logic work:
So !is_user_logged_in() OR
!is_user_logged_in() && !is_page(‘recently-acquired-tinnitus-survival-ecourse’)
But what kind of parens do I need?
Best and thanks a ton! :-)
i updated the notes and faq on the WP site http://wordpress.org/extend/plugins/widget-logic/other_notes/ which might be of some help
i’m a bit confused by the logic you want – it seems like the first case !is_user_logged_in() would be true before you get to OR with the second case which is ‘!is_user_logged_in() AND something’ ie a subset of the first case.
perhaps you’ve got tripped up over too many “don’ts’ and “nots”. try restating what you want in terms of when you DO want the widget to appear.
My widgets are also disappearing when I save, and I’m not quite sure what to do. I am using wordpress 2.7.1 and Widget Logic 0.46.
What should I do to fix this problem?
(I have also left a more detailed question in the forums here: http://wordpress.org/support/topic/278187/page/2?replies=44#post-1110113
Thanks in advance for your help!
replied on the wp forum
Thanks for your prompt reply:
This is where I am now… I posted on the wp forum here:
http://wordpress.org/support/topic/278187/page/2?replies=47#post-1110440
Thanks again!
I’ve been using Widget Logic on my 2.7 WordPress site for a while. But then I upgraded the plugin yesterday and was unable to use WP text widgets. I can’t edit or create new text widgets unless I deactivate Widget Logic first. Any fixes? Thanks!
the good (ish) news is that you are not alone — see the WP forums for one other guy having this issue and helping me with some feedback.
the bad news is that i cannot reproduce this problem with my WP2.7 (actually 2.7.1) install, so I don’t know what to do to fix it. yet.
Can you make the entry box for widget logic bigger or scalable? If I have a long command I can’t see it unless I copy the whole command and paste it into note pad.
Thanks!
i have thought about this – and how to do it as simply as possible. if i make it a textarea rather than a text input that would make it expandable in safari — would that work on other browsers too?
I would love to use this plugin but is it WP 2.8 compatible yet?
Really do appreciate the hard work thats gone in here the logic is awesome and fluid.
But WP is supposed to simplify life , bring more people into the blog sphere (needless to say most of these people don’t even know what php means, translated it means these people are newbies)and most of them will not even know where to begin with this tool .
WP is supposed to be simple but unfortunately this tool does exactly the opposite. More tools like this and the WP market share for the newbies will shrink to a trickle.
May be you should start seriously thinking about developing your tools for CMS – now no one claimed CMS was simple ??
Cheers
vivi
PS: I hope that you will take my feed back in the right spirit?
PSS: Its a disaster with 2.8
I have done some 2.8 testing and it seems fine. Let me know some specific problems and I’ll get on it
Hiya,
with the first portion of this:
!is_user_logged_in() || !is_page(array(1258,1669,1670,1394))
I’m trying to say: “show only when the user is not logged in,” which works all by itself.
Now, what I’m trying to do is say
1) Show only when the user is not logged in as a general rule
2) Don’t ever show on these pages (regardless of if the user is logged in or not). I can also say “don’t show if the user is not logged in and is at the following pages.”
The thing is if I say
!is_user_logged_in() && !is_page(array(1258,1669,1670,1394))
then I think I get:
“Show if user is not logged in and don’t show if user is is simultaneously at one of these four pages.”
Hmmm…just tested it, and it works with the and, not the or.
It’s interesting, because WL starts with
“Show if…”
when I put a not in front of is_user_logged in, I get: show if user is not logged in. That works.
The thing is
When I say
“Show if… !is_page” it’s like it should be “show if it is not this page,” but that’s not correct. When I say !is_page I have to start the sentence with “don’t show,” which somehow doesn’t make sense to me yet.
Well, it’s working, and I wonder you tell WL “show on this category,” does that also mean “don’t show on any other category?” I guess so.
So things can be either positively of negatively formulated. Interesting.
Thanks, this has been fun!
glad it’s worked out! what you have to get your head around is what the logical OR || operator and logical AND && operators are doing.
in your first case
!is_user_logged_in() || !is_page(X)
this is saying ‘show the widget when the user is not logged in OR when the page is not X’ – which means it will be showing if the page is not X regardless of whether logged in or not. which is not what you were after. and if you are not logged in it shows regardless of which page it is.
logical OR is a way of combining when you want to consider either of two separate instances to be true.
so you needed to reword what you wanted as
“Show if user is not logged in AND EVEN THEN, only if user is not at one of these pages”
which is a way of narrowing the conditions – a logical AND operation.
:-)
I am using Widget Logic 0.46, WordPress 2.82, and Thesis 1.51 with a static “Home” page and all posts on the “Blog”page.
I can not get Widget Logic to only show the main widgets (which include Recent Posts, Recent Comments, Archives)on the “Blog” page only.
When I enter “is_page(blog) into andy of these, they disappear from the “Blog” page.
Is this a bug or is there a way around this.
Thank you,
JW
I receied the fix on the widget logic wordpress forum from “greenshady” and the simple fix he gave was to use:
is_home()
JW
EDIT: Disregard what I wrote. It was “user error”. :)
Nice plugin!!!
Ok…now I am having trouble. My Twitter widget isn’t showing up since utilizing this plugin. I don’t have anything in the Widget Logic setting for the Twitter widget. Are there any known conflicts?
Thanks for your information!
awesome stuff mate, made my day
This is a great widget, but I have a question. I’m making a site with many pages, and can’t figure out how to write the code so that a page and all its sub-pages get the same widget, instead of having to make a separate widget code each page (I have 60 + pages!) using this: is_page(‘page name here’)
Great plug-in, very useful. Thanks you for creating it.
However I found a bug. With WP 2.8.2, when widget logic is activated, new widget (without the details in widge logic box) cannot be saved.
The workaround is to disable widget logic, add the widget and reactivate the plug in.
vince, the notes in http://wordpress.org/extend/plugins/widget-logic/other_notes/ has an example that fits what you want
bob, you are not the first person to say this (see also the WP forums), but i have never managed to replicate this issue on any version of 2.8 and WL. FT works on 2.8.3 (v recent upgrade from 2.8.2) and we don’t have that issue. there is some other factor interacting with WL that i can’t debug or take any steps to circumvent.
if you’d like to give me access to your blog (including access to edit the WL plugin on your site), i’d be delighted to give it a go.
This is such cool stuff! Wow! I wonder If I can apply !is_user_logged_in() to a category.
is_category(x) && !is_user_logged_in()
will only show a widget on the category x archive page when the user isn’t logged in
Ha, that was quick, actually, I meant whether I can show or not show certain posts or pages as a result of this kind of code in special fields or something like that. Basically, I want a particular category only to display if users are not logged in (that is they are visitors). It’s not widgets, it’s a category full of posts. :-) I think I figured out a fun workaround, though…
Thanks a ton!
Hi,
I’m having some trouble getting more than one widget to display using Widget Logic.
Works fine with one widget but any more than one and the second wont show.
I’m using Massive Themes running wordpress 8.4 on a server running php 5.5.4
Any help would be GREAT!!
switch to the WP default theme and try as simple a setup as you can. say 2 widgets, one set to is_home() and the other to is_single(), or something as uncomplicated as that. let me know how that goes
i can’t find Massive Themes – do you mean MassivePress?
I’ll give that a shot! Sorry I meant Massive News from Press 75.
Thank you so much for this plugin. I appreciate that you took the time to make a tool that is useful for designers/developers like me
Hi – first of all, GREAT plugin and thanks for creating. My question:
On my site (takesunset.com) I have all the blog related widgets set to appear only on takesunset.com/blog, however, whenever someone clicks on a post they disappear. what function must i input to get them to appear whenever someone clicks on a post? thanks!
One more question – can you add two commands to one widget? For recent posts I’d like to have both:
is_single()
is_home()
can i do that in one widget or would i have to add the widget twice? problem is, i can’t seem to add “recent posts” twice for some reason so i’m hoping i can add both to one widget. thanks!
rob
Thank you so much for making this plugin. It was really useful for me.
Podcast channels are a great add on for any blog. Thanks for the inputs on wordpress set up and themes.
is there a widget logic to use for showing a widget on a post by author. So lets say I have 4 authors and I want a widget to show only on single posts by a particular author? Thank you for a great plug in!
I’ve widgetized my multimedia box on Thesis but I’d like to add a transparent descriptor in the box to help readers understand how to use the widget do you have any tips?
Heidi, turns out the is_author conditional tags aren’t all that useful – in that they only work as if they were ‘in_author’ tags, ie as author archive pages. BUT you can use the get_the_author_ID() function to get the author of the current single post. which means you can use:
`is_single() && (get_the_author_ID()==33)`
to get a widget to appear on single posts by users with that specific ID
I have downloaded Widget Logic, but can not find a tutorial or directions on how to actaull impliment!! Pretty new to Development. Please direct me to HOW TO USE manual :)
Thanks
I am rewriting the widget logic so that i can easily go from
-> Edit Page (a link like “edit widgets”) then it takes me to the widgets page where i can edit the widgets for the specific page. Insted of having all widgets for every page on the widgets page. No need for typing in is_page() logic in the field. It inserts in a hidden field and automaticly. But now i have a problem i want to use the same filter like widget-logic filters the widget in my theme ( show widgets only on certain pages ) So how can i apply this hook to the “sidebar_admin_page” widgets.?? any help would be great. this would be a great update for widget logic anyways!!!!
always on the lookout for suggested additions.
what would “edit the widgets for the specific page” involve? setting a visible/invisible flag per widget?
i have thought of something like adding a ‘write post/page’ box extra that lets you choose a named sidebar for when showing that single post/page. i’d have to work out a way to add to the theme’s declared sidebars, but i bet it’s do-able.
on the write post page i already added a box called “Edit Widgets” so it simply passes the PostID to the widgets page. Originally you have a field in the widget logic where you can type the condition is_page()
there i catch the PostID and insert it:
input type=’hidden’ value=’is_page(‘$_GET[‘post’]’)’
i make the input field hidden, so that the user dont have to bother with typing in conditions. The Next step would be to automaticaly determate which content the link came from and then insert a condition.
For example if you come from a category to the widgets page, auto insert in hidden field “in_category(‘$_GET[‘catid’])” These rules would be no problem for me.
I need help on the Filtering widgets Issue. Please help me in filtering the widgets on the admin widgets page the same way you did in the theme frontend. I only want to show widgets filtered through is_page(‘$_GET[‘post’]’)
maybe we could find a way.it would be a great addition or variation for WL. My msn is vaiz@hotmail.de please contact me
I scribbled the Issue with Photoshop.
http://scoramba.de/Issue.jpg
i’m sorry, it’s not clear to me how you target specific widgets in the first place. and i’m not sure widget logic can filter the admin page the same way it does the main blog.
have you looked at “section widget” or “widget context”? they might suit your purposes
http://wordpress.org/extend/plugins/section-widget/screenshots/
http://konstruktors.com/blog/wordpress/842-wordpress-gpl-widget-context-plugin/
The apply filer method? Your Hook apllies a filter to the registered_widgets.
add_action(‘wp_head’, ‘widget_logic_redirect_callback’);
i tried adding
add_action(‘sidebar_admin_page’, ‘widget_logic_redirect_callback’);
but it seems it not adresses the registered_widgets right.
thank you for the tips and plugin links. But Maybe you ll get an idea.
i don’t think that will work on the widget controls in the same way as it works on the widgets themselves. that will take different code. either way, i’m still not clear how you target widgets to appear or not in the first instance.
and say you click through from a page to the widgets admin, how do you indicate you no longer want a widget to appear. Hoe about when you want a hidden widget to appear again?
the basic idea was to edit widgets in general on a “per page basis”
not to having all widgets from all pages mashed up in one area which is very confusing. only edit the widgets of the selected object would be the magic.
The Widget Logic field disappears after saving the Widget, so I can’t adjust the logic once entered. I guess it’s because of my 2.8 upgrade … not sure as I did that awhile ago. Any fixes yet?
i’m not seeing this on any of the setups i have. what version of 2.8 are you running (2.8.4 i hope) and are you on the latest version of WL (i assume so as you ask about fixes)
i’m running the most current wordpress and widget-logic but the logic doesn’t seem to be working. I put is_page(‘certainpage’) in the logic box but the particular widget still shows up on every single page instead of just the one certain page that i wanted. how does this widget work? I’m use a db caching plugin and css/js concatenate plugin on my wordpress, could those be effecting this widget logic plugin of yours?
have you read through the troubleshooting stuff at http://wordpress.org/extend/plugins/widget-logic/faq/ ?
if your plugins result in caching of any sort, this will stop changes appearing immediately of course.
How does one just have a widget appearing for a particular post, say post 33?
i cannot stress enough how much it pays to read the codex on conditional tags. eg, read this bit on ‘single post pages’:
http://codex.wordpress.org/Conditional_Tags#A_Single_Post_Page
You could put it in bold? That would stress it more.
more, but not enough :-)
Thank You soo much for making this plugin
I needed soemthing like this real bad.
Keep up the good work dude.
P.S. something you may want to add to this plugin
would be an option where what users input into the box will not be what posts/pages you want the widget to show up on but what posts/pages you don’t want the widget to show up on this way I will not have to input soo much.
just a thought :)
you can do that already using the logical NOT exclamation mark. read the notes here on ‘building your own’ code http://wordpress.org/extend/plugins/widget-logic/other_notes/
I am trying to use this plugin to get ttftitles plugin to work in my sidebar. Which I did get to work, but when activated, I lose all of my page code past my sidebar. In my case the footer. If I turn off the WL plugin or delete the function for ttftitles, for the footer returns.
Any Ideas?
Thanks in advance.
sounds like your widget_content filter function is throwing an error. what’s your code? have you adapted it from my code given on
http://wordpress.org/extend/plugins/widget-logic/other_notes/ ?
to check that, change the filter function to return $content untouched.
Hi guys!
THANKS so much for this widget! And I already have a question. The client wants a specific page to be his opening page for his site. The page in the menu is called “Home”. When I go to the Pages>Edit section of the Dashboard, there is no page name showing in the path for me to put in the is_page() code.
The path to this page (on the mockup of this site) is just http://bestbiztips.com/quickmedquote – and I tried putting ‘index’ in the code with no success.
How do you suggest I code Widget Logic for specific widgets to appear on this page?
Thanks bunches!
I’ve been wondering for a long time now, but can widgets be placed only on a specific page? I’m thinking it’s impossible with the way blogs work.
kippiper, what you want is the condition for the front page, take a look at
http://codex.wordpress.org/Conditional_Tags#The_Main_Page
at the differences between is_home and is_front_page. this is asked a lot and IS in the main faq http://wordpress.org/extend/plugins/widget-logic/faq/
more generically if anyone else is looking for how to get widgets on specific wordpress PAGEs, take a look http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
you can use the numerical ID, URL slug, or title of a page. the URL slug is simple enough to find, the ID you can get from clicking to edit the page and looking in the URL for post=xxx
Hi Admin –
Thanks so much for taking the time to graciously answer my silly question. I had looked in the FAQ and obviously was not “cluing in” on the terminology for the answer.
However, I am still having issues. My Settings>Reading is set to have “Front Page Displays” as the static page “Home”. However, when I code in Widget Logic is_front_page(‘Home’), the widget still does not appear.
Am I missing something?
Thanks!
I GOT IT! Thanks soooooooo much!
Widget Logic is great!
question:
How do I check, within sidebar.php if widgets are active for that page? I have div tags wrapping the widgets to create a right column. However, I need to hide those divs if no widgets are appearing on a page. Hope this makes sense.
Thanks for your help.
hmm. i’m not sure what’s your best bet
i was thinking of adding a “widget count so far” global, but that would only be useful AFTER the sidebar has been printed, which would (at bare minimum) include the open DIV or UL tag for your sidebar.
could you use CSS to add “display:none” for that bit of the page under the right conditions? if so, the “widget count so far” would be useful to identify that condition of course, and i’ll add it in to the code.
I think you’d have to add the STYLE section in the footer – i don’t think it would work within the sidebar would it? so that would be something you’d add to your own footer.php template i think
I’m having some trouble getting the plugin to help me change the titles of my sidebar widgets using the ttftitles plugin. I activated the ‘widget_content’ filter then grabbed this code from the ‘other notes’ section of the plugin homepage and put it in my functions.php file:
function ttftext_widget_title($content=”, $widget_id=”)
{ preg_match(“/]*>([^<]+)/",$content, $matches);
$heading=$matches[1];
$insert_img=the_ttftext( $heading, false );
$content=preg_replace("/(]*>)[^<]+/","$1$insert_img",$content,1);
return $content;
}
Am I missing a step? Do I need to add any code to the 'Widget logic' section of the widgets dashboard?
I expect you haven’t used add_filter to connect your function to the filter. Look again at the ‘other notes’ section
I have split my blog into two categories, “blog” and “news”, and display each on a separate page. What would the array syntax be for pages website.com/category/blog/ and website.com/category/news/ ?
Thanks for the plugin!
I have one question.
What code would I put for a widget to appear just on 1 page? the “is” code excludes the page I add.
Hello,
Just discovered this plugin! Will be donating soon for sure :)
I’ve looked here:
http://wordpress.org/extend/plugins/widget-logic/other_notes/
and here:
http://wordpress.org/support/topic/207694
How do I get a widget to show ONLY on a page that is a subpage of a parent page.
This looks close but does not work:
global $post; return (in_array(77,get_post_ancestors($post))); — WP page that is a child of page 77
Thank you very much in advance for your help.
That code will work to find pages that are subpages of the page with ID 77. what are you after – pages that are subpages of any page?
Thank you for plugin, will this work on latest wordpress..
I’ve got it figured out. I had super cache on and it was not showing correctly. The code that worked is pretty simple: is_page(‘141’)
Thanks Alan. P.S. Just made a small contribution to the Cancer Research UK on your behalf. Thanks for a very useful plugin!
Mr Freaky Trigger,
I am glad you enjoyed the Video Tutorial I put together. I sincerely appreciate you linking to it here on your site
Thanks serenine and to anyone donating to Widget Logic’s Cancer Research UK drive.
And thanks too to you Daryl for taking the time to make the video.
Hi, I really love this plugin but I keep running into errors whenever I do conditional statements other than the simple statements. When I add the conditional: !(is_single(‘798’)
I get this error:
wp-content/plugins/widget-logic/widget_logic.php(154) : eval()’d code on line 1
I can’t get it to work on any of the conditional statments other than the basic true value statements. Not even statements like is_single(array(17, 19, 1, 11)) will work for me. I tried switching to the default wordpress theme and it still will not work.
Any suggestions?
EDITED: I figured out the first error, lol. I am ashamed I did, but I still have problems with complex strings; they give error outputs. I’ll have to copy them later to show though. Sorry. GREAT PLUGIN
i tried installing it for almost two days and i’m happy now.it worked.thanks for the plugin- no questions.Perfect!
Thank you so much for the video and explanation. My question is that there is a particular page on which I do NOT want the widget to appear, but I want it to appear on all others. How do I do that?
Hi. I’m really sorry to be commenting here as this has to do with your relocate/upload plugin, but, I can’t for the life of me find anywhere to contact you about this anywhere else. There was a user who had the exact same issue as I am having in the comments at the repository, the filter for viewing the files from the RU folder in media library not working, and it was solved with the changes that you guys made to v.014, but, this has not worked for me and I am having a devil of a time figuring out what is causing this not to work in my instance.
General Settings in WP are: http://domainname.com/wpdirectory
RU settings are:
root: hostdirectory/homepages/hostdirectory/hostdirectory/htdocs/wpdirectory
default: /homepages/hostdirectory/hostdirectory/htdocs/wpdirectory/wp-content/uploads
I can upload to my RU created folders, and the files are then listed in the media library ( however the image does not show up ) but, I cannot get anything to show when I use the pull down menu to list only images in that folder. As well, if I try to move something back OUT of that folder and into the default location, I get a warning from the rename function that the file or directory does not exist ( line 51 of relocate-upload.php ) along with “cannot modify header info” errors from lines 72 and 73. I’m on WP 2.8.6. Do you have any idea why this might be occurring? The host I’m on is 1and1. Do you think it may have something to do with how they name the root folder? I’m really baffled and very much need this ability. I think this is a great plugin that you have written here, and would love to get it working properly. Any help would be greatly greatly appreciated ;-)
By the way, I tried to register a few times for your site and each time got a “fake user” response. I’m real, I promise.
your root and default location paths look unusual, and i think that that might be breaking the string chopping that goes into working out the changes in paths and URLs. which would explain missing previews, and possibly the failure to filter and move back
can you just check for me that you have got those right.
another thing. you say ‘I can upload to my RU created folders’. the method I use with RU is to upload to the default ‘wp-content/uploads/’ folders and use RU to move stuff from there to the special folders. are you saying that you are setting the WP uploader to upload to a specific folder (in the WP misc settings screen)
Great plugin!
Is there such a thing as a WP conditional tag that allows for NOT statements i.w. “is_not_home()”? I’m trying to say that I want a widget to appear on all pages EXCEPT a specific page.
Thanks!
it’s such a usefull plugin – maaany thanks for making it!
Using the arras-theme I have one problem with your plugin with the widget “Last Previews”. I want this widget only appear on “home”. But the command “is_home()” doesn’t work. The widget cant be seen anywhere. What is wrong? Can you help me please?
Your Widget Logic-Plugin seems to be the one I was looking for. :) It does its job very well, but only this problem irritates me a bit.
If found a bug inside the relocate-upload plugin.
While using it on a windows based server, the ABSPATH constant contains the path in windows style but the \ is considered as an escaping character and diseappears.
To correct this, i used url_encore function on the ABSPATH contant on line 102 in relocate_upload.php
Something strange is happening. I am using two page templates. One is “main”. The other is “Gallery”. I am using the conditional “is_template” to determine which widgets show up on template. All my pages work fine except one…(see tab “Information/Let’s Talk”. All pages should look the same except “Gallery”. The only thing I can see that may cause the problem is that there are lots of posts on the “Let’s Talk” page. Any suggestions?
http://www.sidwebb.com/WPress
I feel really stupid….I don’t understand how to use the widget. I’m trying to get certain things to show on blog page but not on other pages. Currently, every page — even static pages with sidebar — have every widget and someone suggested I use this to only put things on blog sidebar. I looked in Admin > Widget but don’t see how to do it.
Thanks!
Sid, have you tried the suggestions in the FAQ http://wordpress.org/extend/plugins/widget-logic/faq/
Sculley, read the notes at http://wordpress.org/extend/plugins/widget-logic/
I read that and it didn’t make sense. Sounds like you have to be a programmer type yes?
if you couldn’t make sense of the screenshots and other notes, then, yes you should consider using it quite a high-level programmer thing.
there are other, friendlier plugins that allow you to show some. check out ‘widget context’ plugin
Just wanted to share this as an example for others who might be struggling with logical statements. Could be a good example to add to the notes. Sorry if it was already mentioned.
I wanted to display widgets on all posts and pages EXCEPT for single posts in a certain category. I figured the following would work:
!is_single() && !in_category(‘category’)
However, this excluded the widgets not only from single posts in “category,” but from ALL single posts. It seemed like the AND operator was behaving as an OR operator. I tried enclosing the whole statement in parentheses, but it didn’t change anything. It took me a while to figure out that this unexpected result was because of the ! modifier.
The proper syntax for this statement is:
!(is_single() && in_category(‘category’))
This will display widgets for everything except single posts in the category named “category.”
Hope this is helpful to someone to make tearing my hair out worth it. :D
Really wish the instructions for TTF integration we’re clearer. Have read and re read the FAQ and Other Notes and like several posters here, am none the wiser. Shame
I’m having the same issue as kippiper was. I can’t get this plugin to work when I’ve defined a static page as the front page of my site. I’ve tried setting these variations in the Widget Logic field of the widget with no results:
is_front_page()
is_front_page(‘4’)
is_front_page(‘page-slug-here’)
I’ve even tried is_page() with the ID and slug of the page, but the widget never shows up. I have “wp_reset_query” checked, and it’s not a theme issue, as I’m getting no results with the default WordPress theme either. Any ideas?
One other thing – in trying other conditions, I’ve realized that the Widget Logic conditions aren’t working at all on my site. Either the widget displays on all pages or none, no matter which condition I try. I’ve attempted using the conditions on three different widgets with the same results. I’m using the Thesis theme, which has never clashed with any other plugin I’ve tried. Very odd.
Additionally, wp_reset_query unchecks itself every time I leave the Widgets page in the WP admin.
if you tick “use wp_reset_query fix” and hit the ‘save’ button next to it, it should stick no bother. what version of wp are you on?
Unfortunately it doesn’t stick – wp_reset_query is always unchecked as soon as I leave the Widgets page. I’m using the most recent WordPress upgrade (2.9.1, I believe?)
I ended up switching to Slayer’s plugin – of the 3 I tried, it’s the only one that works. It might be a combination of my theme and the widgets I’m trying to implement this on, not sure!
this site is 2.9.1 and i don’t get that behaviour. i would love to know if switching to a wp default theme cured that issue. (also if it made the logic work.)
I tried switching to three other themes with the same results. Really have no idea what the problem was and why the Slayer plugin solved it. I’m sorry I can’t be of more help!
I am not a php coder so most of this logic code makes no sense to me at all.
I just want a line of code in Widget Logic to NOT display a widget on the Home page.
Will this do it?
is_not_home()
As an update—and when I use what I think is the logical line:
is_home()
The target widget disappears from the Home page and all other pages too, which is not what I want!
I’m using WP2.9.1 and the Flexx Canvas 2.0 theme from ithemes.
And more—when I set
is_front_page()
It does the exact reverse of what I want. The Home page displays the widget and the other pages do not!
Is this to do with using a static page?
Driving me nuts.
To eat my own dogfood, the correct line turned out to be:
!is_front_page()
Hi, I appreciate your widget-logic plugin’s approach, but am hesitant to install since it says you have not updated the plugin in many months (Last Updated: 2009-6-14). Do you anticipate keeping this plugin current?? Thanks.
Looking at the Compatibility widget on http://wordpress.org/extend/plugins/widget-logic/ says its working fine on 2.9.2 – i will update the ‘compatible up to’ text
I’m very very thank, because this plugin is sooo great and very usefull. Very great. I sue for many site. thanksss :)
Why do I use does not work!
Works for me. Using it on version 2.9.0 Thank you.
thanks.
i’ve just updated the code to clear up the resetting wp_reset_query option that has been haunting me/the code for a very long time
thanks for the great post
A suggestion is to add a drop down of pages/subpages to choose from rather than a writable text field.
Thanks
Cheers. I have of course thought of something along those lines – of making it flip between free text code and a GUI set of tick-boxes/menus. there are other plugins out there that already offer something like that – I personally don’t like the way they’re done and I don’t want to duplicate their functionality either (people can use them instead).
Also whenever I think about what to offer in the GUI, I get stuck thinking “what IS the most common things ppl will want”, between offering lots of confusing options, or only offering a few basics that will suit a small %age of ppl. at one point i was even pondering a user-defined library, but that was getting even more complex ui-wise, so in the end i’ve stuck with the ‘hardcore simplicity’ i started with
Awesome plugin, this is really appreciated, ive been searching for something like this for weeks without any luck, Thanks
First off: amazing plugin! Thanks for all your work.
I’m using Widget Logic to display ads (OIO Publisher) in my sidebar on the home page and when a certain category is chosen.
Using
is_single() && in_category(‘fractional’)
to display the ad only on posts in the fractional category.
Which it does. But the problem is about 20px of the sidebar where the ad would sit, if it displayed, is displaying on every other, non-fractional post.
Any ideas why this might be happening?
Thanks a million!
hard to say for sure, but it *sounds* like a CSS issue. give us a link. (i couldn’t see it on your linked site)
You’re right: it’s a bleedin CSS issue. I’ve moved it to the left sidebar and all is well.
Thanks!
Dave
I am not the most well versed person when it comes to php, but I was hoping for some assistance.
I am using the widget logic plugin with ttftitles, but have had problems rendering.
I get this error: Warning: Missing argument 1 for the_ttftext(), called in /home/skyandcurb/blog.skyandcurb.com/wp-content/plugins/widget-logic/widget_logic.php(161) : eval()’d code on line 1 and defined in /home/skyandcurb/blog.skyandcurb.com/wp-content/plugins/ttftitles/ttftitles.php on line 980
That is when I use “the_ttftext” in the widger logic form, however when I use “the_ttftext(Feed, $echo=true, $style=”navigation”)”
I see the style, but no widget box. The “Use ‘widget_content’ filter” is checked and I have the filter code in my functions.php file.
Are there any suggestions due to my lack of knowledge? Thanks
works perfectly for me, thnx guys….
@ jnforyou
you don’t need anything in the per-widget ‘widget logic’ field to make the ttftitles thing work. all you need is the filter option ticked and the code you’ve put in the functions.php
Alan, Thank you for the quick response! The only problem I see now is only the first widget is using the ttftitle. Again, this may be my lack of php knowledge. But after seeing this, I’m wondering if there is something in functions.php overriding this?
the function i supply is tied to a specific format of widget that your sidebar might not be conforming to. the matching expression used “/<h2[^>]*>([^<]+)/” basically takes the first text after a and before the next HTML tag to give to ttftitles. it may be you need to adapt that.
For troubleshooting, you can check that the filter is working and applying to every widget by changing
return $content;
at the end of the function to
return $content.”WIDGET_CONTENT FILTER WORKING”;
or something like that, which will add that extra text to the end of each widget.
Thanks again! I believe I have it figured out. in my functions the sidebar arrays were calling on:
‘before_title’ => ”,
‘after_title’ => ”
I deleted the heading class, because I figured it was overriding the ttftitle and it worked great. Only one widget it giving me trouble, but I am going to check its styling.
glad it’s working out for you.
sorry that the WP comment system mangled my expression code originally (and your before/after_title code too?)
There are some very usefull information here , thanks
This is one of my favorite plugins. It works flawlessly and I’ve never had an issue with it. It does what it’s suppose to do and does it very well.
My only trouble is locating the right conditional tags for the chores I want it to perform. For example, I have a couple widgets I hand coded and I only want them to appear on certain posts. However, I have a lot of posts and sticking them all into a conditional tag like ‘is_page(array(42,55,77))’ would be a pain.
Is there another conditional tag that I could use to do this task in a more simplified manner?
Thanks again for the great plugin.
you could use tags, post metadata or html comments in the post to control the appearance of widgets, eg:
on posts tagged Widget X:
is_single && has_tag(‘widget-x’)
on posts with ‘widget-x’ in a ‘show_widget’ custom field
global $post; return (is_single() && in_array(‘widget-x’,get_post_meta($post->ID, ‘show_widget’)));
i haven’t tested these – i’m just throwing out a couple of ideas that might need tightening up. Hope they give you some ideas.
Thanks for the reply, but I was really hoping for something more solid, something tested and known to work.
those will work, but i was only suggesting possible approaches. how do you want to control when the widgets appear? give me a specific way of working and i’ll try to work up a specific way to do it.
Sorry, wasn’t trying to be difficult. I just wanted to know if there existed some conditional tags that would accomplish what I am trying to do, but in a more simplified manner.
no worries. just think of a convenient approach you’d like to try and I’ll see what it suggests
There is no approach – I just want to know if there is any conditional tags that can do what I’m trying to do, but in a simpler way.
you say “I have a lot of posts and sticking them all into a conditional tag like ‘is_page(array(42,55,77))’ would be a pain.”
but what sort of condition wouldn’t be a pain if you just want a widget to appear on arbitrary, but set, pages? somehow you need to specify the list of pages, and if it’s not going to be in a brute force listing wrapped in is_page(array(…)), then how?
my original suggestions were to mark the pages with existing features of WP (tags, custom fields) which are relatively easy to admin when writing/editing the post. rather than having to edit widget logic each time.
Ok, I understand what you’re saying now. So how would I have it appear on just blog posts, would I make it is_single && has_category(‘blog’) ?
Well I tried out your suggestion. I tagged the blog posts I wanted the widget to show up on with the word “blog”. Then I entered is_single && has_tag(‘blog’) in the widget logic box, but nothing happened.
I guess it’s back to Google. Thanks anyway.
my mistake, that should be
is_single() && has_tag(‘blog’)
missing () there the first time.
That doesn’t work, either.
It has to have quotations around it – ‘is_single() && has_tag(‘blog’)’
Now it works, but the only problem is it shows up on every page.
Do you know of a place or maybe someone who knows about these conditional tags? That’s really all I wanted with my first comment – to find someplace or someone who knows what they’re doing.
i don’t know what to tell you, is_single() && has_tag(‘blog’) (no extra quote marks) is working here when i test it.
if you have already checked out the wp forums (linked above) let me know if you find any better place for finding people who know what they are doing wrt WP.
I already tried using is_single() && has_tag(‘blog’) and it doesn’t do anything. Maybe it’s my theme. I dunno. I’m sorry. I didn’t mean to come off as rude with that last comment. Thanks for trying to help.
Since I could not find any conditional tags to accomplish what I wanted I’m going to create the sidebars myself (in my PHP files) and then code them to appear where I want. Guess I don’t need this plugin anymore then.
Thanks!! I use this plugin in all my sites …
A coding friend of mine came up with one that works:
is_single(array(17,21,35,77,87,34))
If anyone needs help with this please let me know for my coding friend obviously knows a lot more about this.
http://codex.wordpress.org/Conditional_Tags implies that is_single(array(…)) and is_page(array(…)) should amount to the same thing. is there a difference? is one of these simpler than the other?
Alan, one references pages, the other single posts.
cheers – so is_single doesn’t work with pages! that is news to me i think.
so my original attempt should be rewritten as: is_page() && has_tag(‘blog’), so pages tagged appropriately will work, saving you from updating the array every time you write a new page
An easier method would be to use:
is_page(array(17,21,35,77,87,34))
For categories you can use:
in_category(array(1,2,3))
— Returns true if the current post is in either category 1, 2, or 3.
!in_category(array(4,5,6))
— Returns true if the current post is NOT in either category 4, 5, or 6 (note the ! at the beginning).
Hi,
I have an error code. I tried a couple of ways, sorry I’m very new to php. I ended up using an example from post 268
The error message is
Parse error: syntax error, unexpected ‘<' in /home/blah/blah/wp-content/plugins/widget-logic/widget_logic.php(161) : eval()'d code on line 1
Did I enter the code wrong? Thanks! :)
Okay, I’m back. I did enter it wrong I added something extra, oops. Thanks! :)
What plug-in/widget are you using to show an author’s most read posts when you are reading one of his posts? I am guessing it is a combination of Widget Logic to detect that it is a single page, with some other plug-in or widget to fetch the list of posts. But I can’t seem to find it.
I think all blogs should have a page like this, showing what plug-ins/widgets were used to setup the blog. Too often you see something you would like to implement on your own site, but have no idea how it was achieved. Keep up the good work!
it’s code i wrote myself. there’s a few author specific widgets on FT and nobody seems to have written widgets I wanted that are ‘multi author aware’. most widgets have a single config page and don’t let you do it per author. another (regular) plugin, which i can’t recall right now, updates a post meta_field with the hits.
the widget logic is ‘is_author()’ – it was ‘is_single() || is_author()’, but the single post sidebar was getting full.
the core of the widget code is:
global $wpdb, $wp_query;
$post_obj = ($wp_query->post);
$query = “select p.ID, p.post_title, 0+m.meta_value as post_hits \
from wp_posts as p left join wp_postmeta as m on p.ID=m.post_ID \
where p.post_author='”.($post_obj->post_author).”‘ and m.meta_key=’views’ \
order by post_hits desc limit 20″;
$items = $wpdb->get_results($query);
and then code looping through $items.
Thanks! That should do the trick! The post updating the views is probably WP-PostViews, as listed above.
First of all: great plugin!
I noticed the following: on a page, where a widget is not shown (because of the widget logic) wordpress creates the widget area div and an emtpy list though. How can I prevent this?
short answer: you can’t, not with widget logic.
long answer, you have to work out which pages won’t have any widgets and switch to a template that doesn’t have a sidebar, or have logic that doesn’t produce a sidebar in those cases, or that uses CSS to display: none the sidebar.
somewhere up this thread i offered to update WL to add a global $widget_count that would give programatic access to how many widgets had been output on a page so far. nobody seemed keen on that cos you need to know BEFORE you start declaring sidebars which CSS/template to use.
hope this points you in the right direction
Thank you for the quick answer. I already tested the “display:none”-workaround. It even works without new templates because you can use the slug class in the body-tag. :)
Hi there,
Firstly I just want to say this is an amazing plugin, many thanks for making it available..
I wonder if you could tell me how to do this, I am going insane trying Lol..
I eventually found out that…
!is_front_page()
shows the widget on every page “except” the home page, this is what I need and works very well…
I also want to make it so it does “not” show on a few more pages.. for example my..
contact_page
about_page
Could you please tell me how to add more pages…
I have tried all sorts and still cannot add more pages..
Many thanks.
!is_front_page() && !is_page(array( … , … , … ))
i think
Many thanks for your reply..
I applied this code
!is_front_page() && !is_page(array( contact , … , … ))
This stopped the widget showing on my “home” page and my “contact” page superbly…
Trouble is I could not get it to work with pages that have more than one word in the title..
For example..
www,mysite,com/daily-thoughts/
I tried it for the home page. contact page and the “daily thoughts” page…
!is_front_page() && !is_page(array( contact , daily thoughts , … ))
I tried many variations but could not hit the nail on the head?
See http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
you should be able to use the page ID (a number), the page ‘slug’ (a string with no spaces in it), or the page title (a full string). but the strings in (definitely the last case) should be in quotes.
glad it’s working!
BRILLIANT!
The page I.D 65 in this case did the trick..
!is_front_page() && !is_page(array( contact , 65 , … ))
Thank you.. I will come back on payday and make a donation to your cancer appeal..
Many many thanks…. :]
I’m struggling with some conditionals. Reading the codex, in Snippet 4, there is the function is_tree($pid). I’ve copied this into functions.php and add is_tree(‘602’); to the Widget Logic bit, but it doesn’t work.
I changed is_tree to make it just return true, but that didn’t work either, it’s like it can’t see the function I’ve added. What might I be doing wrong?
either the function is not in the right file, is copied and pasted wrong, or the WL code is wrong.
first check that the function has definitely been added to the functions.php of the running theme. then try calling is_tree() with no parameters. you could also try calling the function elsewhere in your theme – in the footer or somewhere innocuous.
I added it to WordPress’ functions.php file, rather than the themes. Is that not…right? <– WP Novice
aha. it should be functions.php in the theme. if there isn’t one, just make one.
How have you realized the sliding articles on the homepage? Is that a plugin or widget? I see the sliding effect is some jquery magic, but what query do you use to select the articles to be displayed?
it’s not a plugin – it’s custom code in the FT theme that uses http://jquery.malsup.com/cycle/ which is VERY easy to use
Excellent!
How do you select which posts to highlight? What query do you use?
query_posts(‘showposts=5&tag=featured-content&orderby=rand’);
another detail (you can see this in the HTML) is that I pass the cycle action an ‘easing’ parameter to make the transition slightly cuter. This is cos cycle can use the easing options provided in this:
http://gsgd.co.uk/sandbox/jquery.easing.php
Hi there,
This plugin is great and it works great for me 99% of the time. The reason I’m posting here is because I can’t get it to exclude more than one parent page.
The code for excluding one page and a parent is;
global $post; return !(is_page(219) || ($post->post_parent==”357″));
This works.
Now when I try to add to this, nothing seems to work, I’ve tried the following and none work;
global $post; return !(is_page(219) || ($post->post_parent==”357,409″));
global $post; return !(is_page(219) || ($post->post_parent==”409″) || ($post->post_parent==”357″));
global $post; return !(is_page(219) || ($post->post_parent==”409″)); || ($post->post_parent==”357″));
Any ideas as to where I’m going wrong would truly be appreciated!
That 2nd one is in the right form. So if it’s not working it could be that you are using curly quotes or that you have the wrong numbe. In there
Hi again,
Thanks alot for getting back to me so fast!
I tried the second one again;
global $post; return !(is_page(219) || ($post->post_parent==”409″) || ($post->post_parent==”357″));
It’s not working though, it excludes all the pages apart from the children of 409 and 357. I want to exclude all the children of 219, 409 and 357 but this is not working for me.
I double checked the numbers and they are correct. What are these curly quotes and what changes would I need to do to my code to make this work?
Thanks again for your help!
I’ve rechecked my code and actually only work when the same page number is used as below;
global $post; return !(is_page(219) || ($post->post_parent==”219″));
So this is what I want, it’s excluding page 219 and all her children.
All I need to do is add a few other mother pages to the above code, I tried my logic, but it keeps failing! :( Everytime I try to add to this, it just starts excluding all the pages and only including it on the children pages I’m trying to exclude from! It’s like it’s teasing me! :)
“I want to exclude all the children of 219, 409 and 357”
then you need to add || ($post->post_parent==”219″) in there too – which is doing the job of excluding the children of 219. the is_page(219) will also exclude page 219.
when the code is getting a bit repetitious like this, you could try reformulating using PHP’s in_array like this:
global $post; return !( in_array($post->post_parent, array(219,357,409)) );
wordpress’s own is_page can take an array for multiple values too, so if you also wanted to exclude those parent pages:
global $post; return !( is_page(array(219,357,409)) || in_array($post->post_parent, array(219,357,409)) );
“His name is Alan and he’s the man!”
Thanks buddy!
I used this code;
global $post; return !( is_page(array(219,357,409)) || in_array($post->post_parent, array(219,357,409)) );
It works perfect!
Hello,
I’m using widget logic on wordpress to show some widgets only for logged-in users. I do this with the tag “is_user_logged_in()” and it works. But now I want it exactlier, so that the widgets are shown only to specific users. Can I do that with this tag and the user-id? or is there any other possibility?
Hello! For my the Widget Logic plugin work very good! Very clear & clean! congratulations! :D
I discovered your plugin just over a week ago and loved it.
I upgraded tonight to WordPress 3.0. I realize this is a RC, and not finalized.
But I think the plugin is giving me a problem. I am not sure, however. I have several plugins installed, and cannot seem to isolate it to just one. But I wanted to let you know in case you planned to take a look at the compatibility with the newest version of WP.
Cheers. I tried a local WP3 very quickly and didn’t notice any major changes in the widget code – but i was not putting any real effort in. If you could let me know what the problem was, that would be immensely helpful.
The problem that I can’t isolate to just one plugin is a white screen fail for installation. The plugin doesn’t install, and then I can’t access the plugins menu at all, it just goes to a white screen. I rename the plugin folder on the server as a quick fix…
PS, I am glad I kept this window open. Do you have subscribe to comments on this site? I wouldn’t have known you replied.
doesn’t sound like an issue with Widget Logic (if that’s the one you are talking about), it sounds like a much larger issue. but i will take a look.
our hosting company limit the plugins we can use, so we’ve not got any ‘subscribe to comments’ functionality. i’m not even sure they would let us send e-mail from the server.
I have again briefly checked WL on WP3 and if there is a problem it’s not obvious to me yet.
Thank you, this is by far the best widget I’ve found! There is no way I would have been able to get the look I wanted without it, plus it works perfectly…
Alan,
I’m back with another question about widget logic with ttftitles. This time alternating styles. Currently in the functions file my two widgets look like this:
if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘name’ => ‘standard’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
if ( function_exists(‘register_sidebar’) )
register_sidebar(array(
‘name’ => ‘footer’,
‘before_widget’ => ”,
‘after_widget’ => ”,
‘before_title’ => ”,
‘after_title’ => ”,
));
Now, I’ve tried to add the “widget_style_a/widget_style_b” code supplied on the widget logic plugin homepage to replace the original filter code for ttftitles, but I’m not sure the exact values that need to be addressed changed in regards to how my css works. Any help is much appreciated Alan. Thanks
whoops, i actually have a div container stated after “before widget”=>
(div id=”%1$s” class=”widgetfooter %2$s)
and it closes right after “after_widget”=>
Thank you for the time you spent on this post. Know that your work is much appreciated. Keep it up!
This is really interesting. This is one of the reasons that I love surfing. You’ll never know what you’ll find.
Hello,
firstly, I would like to say how much I LOVE THIS PLUGIN. Good job Alan!
Secondly, I have an issue:
I want to show a particular widget ONLY on ONE child page. Can anyone please tell me how?
just one specific page, or one child page per parent page? You should be able to get what you need between
http://wordpress.org/extend/plugins/widget-logic/other_notes/
and
http://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
Hi,
I’m using widget Logic (0.47, with WP 2.9.2) and I’m trying to use more than one condition but it doesn’t work.
I tried to write something like this
is_category(‘cat_name’) && has_tag(‘tag_name’)
and something like this
is_category(‘cat_name’) && is_tag(‘tag_name’)
but neither of them work.
Any idea?
Thank you in advance
Filippo
if you want the widget to appear when either one OR other of two conditions is true, then that needs an OR. if you use AND it will only appear when both condition one AND condition two are true.
AND = &&
OR = ||
hth
Thank you. I treid again but the tag sentence doesn’t work. If I try to write only the category sentence it works, if I try only the tag one it doesn’t work…
obviously if I try both they don’t work.
Any idea? Maybe a spell mistake?
Thank you again
careful of the difference between is_tag (this is the tag page X) and has_tag (this post has the tag X)
http://codex.wordpress.org/Conditional_Tags#A_Tag_Page
other than that, and looking at the codex page, I don’t think I have any more advice, sorry.
I understand the difference between is_ and has_ but what I mean is that simply this sentence doesn’t work, and I don’t know why… Don’t you know about conflicts with other plugins?
There are conflicts with some plugins but they are with widgets and widget-altering functionality, not with conditional tags. Take a look at the FAQ (link above) for some troubleshooting ideas.
For some reason when I enter some widget logic code, the widget is removed from all pages rather than the single page. I’ve tried is_page(#) and is_single(#) and in each case the widget dissapears completely from the site on every page. Also, I can’t seem to get is_page(array(#,#,#)) to work. Any help would be great.
have you checked what happens in a default theme (many themes have code that interferes with some conditional tags working as expected)?
A useful way to troubleshoot generic problems like this is to use a PHP widget (set with no Widget Logic so it always appears) and get it to print_r the conditional tag, so eg print_r(is_page(6)) or whatever it is you are putting in instead of #
Hi Alan,
Been a long time happy user of Widget Logic and congratulations on your plugin!
I have a question.
I am developing a WordPress site that is mainly based around Pages not posts.
I have a need to have different content in various widgets within sidebars for about 100 Pages.
Would the use of the ‘widget content filter’ option allow me to ‘pull’ different content for each widget depending on the Page ID?
Whilst I am not a coder if I knew it was possible I could hire a coder to do it for me.
Please advise.
Regards,
Ray
You could, but that would be a very roundabout way of doing it. Sounds more like you need a widget building – the key to which will be knowing how to link the page ID with the content you want to appear
This might be a stupid question, but I am confused, even after reading the FAQ and other documentation available over at the the WP plugin site.
Where exactly do I put the code? I’ve tried putting it in the Widget logic box in the widget itself, but this doesn’t seem to do it.
I’m running WP 3.0 and Thesis 1.7. Don’t know if that makes a difference.
This pluggin work on WordPress 3.0 ? Doesn’t appear to…
I’ve just updated this site (FT) to WP3 and widget logic is working fine with WP3. I’m looking for anyone having problems with WL and WP3 that’s willing to try some troubleshooting. A small minority of people seem to have problems with WL and WP3, and I’d love to know what combination of configurations they have that are causing the issue.
I’m trying to use Widget Logic to keep a widget from appearing on a specific page, as well as from appearing on any page from a specific category (the page number is 6243 and the category number is 31). This is what I placed in the “Widget logic” field of the widget in question:
!is_page(6243) || !in_category(31)
Using that string, the widget still appears on page #6243 and all entries from category #31.
If I place in the “Widget logic” field only “!is_page(6243)”, the widget no longer appears on that page … but once I add “|| !in_category(31)” to the string, it breaks.
Also, if I enter only “!in_category(31)” into the “Widget logic” field, the widget no longer appears on all pages within category #31 … but once I add “|| !is_page(6243)” to the string, it breaks.
Any ideas?
(I’m using WP 3.0.1)
You want
!(is_page(6243) || in_category(31))
Hey Alan,
Great job on Widget Logic plugin. Got a curly one for ya!
I’ve hit an interesting corner case in the logic. My page slug actually contains the word “return” – the slug is “investment-returns”.
So my initial logic is_page(‘investment-returns’) was throwing unexpected $end errors.
I tracked it down to line 155 (I’m running version 0.47):
$wl_value=(stristr($wl_value, “return”))?$wl_value:”return (“.$wl_value.”);”;
In other words – if string CONTAINS the word return then use “as is” otherwise wrap in “return (…);” to evaluate to true/false.
Of course, in my case, the string DOES contain “return” – so it never gets “wrapped”.
I can code around it by putting “return (is_page(‘investment-returns’));” in my widget logic – but I’m giving this to my end-user to update and that could confuse them.
So, I have added an extra line after 155 to check that the condition STARTS WITH “return”:
$wl_value=(stripos(trim($wl_value), “return”)==0)?$wl_value:”return (“.$wl_value.”);”;
I’m sure there is a more elegant way of doing this – this is a quick hack.
Anyway – thought I’d pass it on. Hope this helps!
Steve
Great WordPress Plug-In, will be featured as the Plug-In of the day on our website on August 18th.
Thanks,
Jamie
steve – yes that issue has cropped up a couple of times with people. The problem with your 2nd workround is that often logic doesn’t have to start with ‘return’ – you can have multiple statements separated by ‘;’ and then the final one does a ‘return $value;’.
The only way to detect if a ‘proper’ return statement is in the string is a full parsing of the code – which is way beyond what I want to do with the plugin! My first pre-release version of WL opbliged you to supply full code like “return is_home();” but when it became obvious that 90% of logic would be a simple conditional tag, I added the code to wrap it in return ().
If you want to hide the complexity of full statements from your users, just mandate it always has to be a single statement, and then change that line 155 to ALWAYS wrap it.
Jamie – awesome. thanks for the heads up
Thanks for the work and upkeep on this interesting widget.
I’m having some trouble. The actual widget is not appearing in my Admin. I get the Widget Logic Options menu at the bottom of the page, but it’s not appearing in my widget list above. Since it’s in my admin page, I assume this has nothing to do with my theme. Any ideas?
[Update]
…clearly I should’ve explored more…I just noticed the fields added to all my widgets…sorry to waste your time.
Will widget-logic get an update for wordpress 3.0.1? That’s the version of wordpress I’m using, but the available download in the wordpress plug-in directory has the version for wordpress 2.9.2.
I can’t seem to get WL to work on my WP 3.0.1 at all. Even the simplest is_single() or !is_single() doesn’t work… my widgets appear no matter what. The WL version is 0.47. The wordpress plugin page says that it works with 3.0.1, with 7 people saying it works, but no luck here.
Perhaps it’s something with my theme? I’m open to suggestions. Thanks and I’m really looking forward to getting this valuable plugin working.
It might be your theme, yes. Try switching (briefly) to a standard theme – the new twenty10 and the old default themes work OK
Mitch, it works fine with 3.01, you’ll see the compatibility widget on http://wordpress.org/extend/plugins/widget-logic/ shows 100% of people say it works (well so far).
I haven’t had time to get into my code repository and update the ‘compatible up to’. I want to put in some small tweaks to the code too, so i’ll save it til i get that time.
@Alan – Thank you sir I got it working. Turns out I removed wp_head(). Once I put it back in it worked like a charm. Thanks again!
OH! Great
this arcticle is interesting. Do you agree with me?
I have a questions using the plug-in. The site I am working on have page and sub-pages structure as follow:
Products
– Overview (products/overview)
Solutions
– Overview (solutions/overview)
The problem those page have the same name and it can not be changed.
How can I get the plug-in to recognize the sub pages which have the same name (Overview) based on the main page without changing its name?
Not sure if you understand what I am trying to do any help would be greatly appropriated.
Thank you.
You could use the page’s numerical ID rather than the name/slug. One way that you can get the ID of a page by hovering over ‘edit’ in the list of pages and seeing what it says post= in the URL of the link
I’ve made that suggestion but that’s a no go. They want to keep the name because of site map and external links. So page id is not an option. I also mentioned to change the name to solutions_overview and products_overview and that’s not an solution either. :-(
is there a way to work around that?
i meant you can use the ID in the widget logic – there’s no reason not to use the ID there. I am assuming you want something like widget A to appear on Overview (the child of Products) and widget B to appear on Overview (the child of Solutions).
Then in widget A you use logic like is_page(105) and widget B you use logic like is_page(209)
This should have no bearing on site map or links.
Alan, it works. I thought I have to change Permalinks to display page ID in order for it to work. Thanks for your help.
I love this plug-in – it’s been a huge help, especially since some of the posts on my product review site are supposed to appear on ad-free pages and this widget gives me an easy way to categorize my posts so that will happen correctly. It’s been working perfectly for me, and still is with one small exception that I just noticed tonight.
I use “!in_category(‘BH Review’)” on the widgets that I don’t want to appear when the post is in that category, and that part is still working perfectly. But – all of a sudden on my main blog page, those widgets aren’t showing up either. Not having any of my ads on my main page is definitely a concern, so I’m hoping that you might have an idea of why it’s doing this all of a sudden?
My blog is http://www.momstakeonthings.com. The posts in the “BH Review” category are the ones where the ads don’t show up – they do show up (as they should) for single posts in every other category. But not on the main blog page… Help!! And thank you!
!in_category will also return true or false on any page that has a list of posts where the last post is in that category (sometimes it’s the last post, depending on how crazy the code in a theme is).
so you just need to tighten up your logic. something like
!(is_single() && in_category(‘BH Review’))
ie don’t show it when it’s a single post that’s in that category.
Widget Logic… I LOVE you :)
Aw lovely. Tell it to the totaliser: http://www.justgiving.com/widgetlogic_cancerresearchuk
Currently 200 quid, 40% of my target
But, THANK YOU :-D
Hi,
as it was said heaps before me, this plugin is awsome!
There are all sorts of complicated scenarios in the comments and I can’t work out what I need to do. I’m sure it’s been covered before but I can’t seem to find it – what do I do to apply widget logic to child pages as well as the parent one. (I guess I can just name all the pages separately but that means if a new child page is added later, it won’t be included automatically, right?) many-many thanks!
In the OTHER NOTES section of the WP repository is an example using get_post_ancestors that you can adapt that will cover children and even grandchildren posts (and so on, at least I believe). You need to add in an extra test to check if the current post is the parent too, so an || $post->ID==77, or something like that will do the trick.
good hostings
CHECK OUT singer/songwriter MICHIA MONIQUE ON http://www.reverbnation.com/michiamonique
Widget Logic is really nice!!!!
I’m building a website where I would like to put unique content on both sidebars on nearly every page.
Are my expectations unreasonable? Can Widget Logic pull this off?
Thank you in advance!!!
I’m trying to write some conditional statements and I’m having trouble combining statements. Do you have examples of combining statements???
Hy there,
this is a great plugin to easy manage the widgets on my website.
But im aving problems to put 1 widget happering in the categorys…
home(), pages(), is_single() works just fine… but when i try to put on category it dosent hapear anything. And i dont knwo where the problem may be.
Can u help finding the problem here?
thx
what logic are you using to identify a category?
Good day and happy new year!
I too am delighted with your widget-logic plug-in, and it is working very well allowing me to display social icons only on defined pages. But, I am also trying to restrict a series of RSS feeds to a single page.
I am in WP 3.0.4, and I CAN display more than one feed in a page through the WP base framework–I am NOT using an additional RSS plugin or widget plug-in,– but I cannot get widget-logic to restrict those feeds to a dedicated page. Is there something “extra” I must do, or is there something inherently conflicting between feeds and the plug-in? I am using the conditional is_page(‘Name of Page I Want the Widget On’)
Your consideration is much appreciated. Thank you and best wishes!
S.W.
PS to RSS Q:
By the way, I wish to come back and say that I CAN restrict the feeds to the homepage using is_home(). But, I want to restrict the feeds to another page. I have tried writing the page name in the conditional to be case sensitive as they are written in the navigation menu, to be all lower case, and to place dashes between each word in the title. None work. Am I missing something? Thank you, again! / S.W.
Sigh…sorry to clutter your board! I have just found that the plug-in also will not work with a simple text field in that widget area. Could there be something wrong with the widget code itself or its interaction with the plugin? I have no idea how to check for this or even what to do if I found a problem. I am so sorry for the hassle. I hope you are still checking this board! Cheers!
Hi there! I’m at work surfing around your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts! Keep up the great work!
I get how to use Widget Logic to allow widget to conditionally *appear* on specific pages, but what conditional tags exist to *suppress* a widget from appearing on specific pages? For example, I want a widget to appear on every page except for, say, the “About” page. What is the conditional tag to suppress a widget from displaying on only that one page?
Thanks.
After thought to my initial post…
Right now I’m thinking the workaround is to use an array with is_page() to include all the pages (except the one(s)) that I want the widget to appear on. Please tell me there’s a better solution. ;-)
I figured it out the solution to my original inquiry:
! (is_page('about'))
Thanks!
Oh, geeeeeeze! I was just at the Widget Logic plugin site on WordPress and saw the examples. Turns out the solution is even slightly simpler than what I posted.
!is_page('about')
The ironic thing is that the example is the same example I inquired about. LOL! :-)
=Jeff
Not sure if someone allready has reported but when wp-debug is set to true
Notice: Undefined index: callback_wl_redirect in /httpdocs/wp-content/plugins/widget-logic/widget_logic.php on line 137 appears manytimes
100k downloads from WP.org, and 250 quid raised for charity.
i really must put in all those little tweaks and improvements suggested in the comments above – for which many thanks everyone.
I have no problems using single words example: in_category(Education) , but when I try using Health & Fitness, in_category(Health & Fitness), it doesn’t show-up in my side bar.
Any clue?
Thanks
Lloyd
http://codex.wordpress.org/Template_Tags/in_category seems to think that should be fine (so long as you are putting in the quotes). to troubleshoot you could try putting in
print_r( wp_get_object_terms( $id, ‘category’))
in your code, where $id is any post ID in the category you are having problems with. This will print an array of varying IDs and strings that you can use to match that post with in_category(X).
Thanks so much for your response, I made a simple change and it worked:
Health & Fitness
to
Health-Fitness
Thanks
Lloyd
Hello to all, i’m looking for a solution on my website http://www.lovingragusatravel.com
As you can see, my home page redirect on two different section of the website, translated with ZDMultilang plugin
http://www.lovingragusatravel.com/it and http://www.lovingragusatravel.com/en
(i’m translating in this days)
What i’m looking for is a conditional tag that select the widgets for each language, showing respectively the italian widget when user navigate through the italian section, and the respective for english.
I can’t use categories or IDpage beacuse ZDM plugin maintain the same Id page and only add “en” or “it” after the home page URL
Some workaround for this?
Thank’s for your help.
geris
i don’t know that plugin well, but the FAQ implies you can get the locale code with the function zd_multilang_get_locale()
so try zd_multilang_get_locale()==’it’
etc
One of the better plugins, thanks.
Just spent the best part of 6 hours looking through a load of widgets, switching widget-logic on and off, to discover a rogue – instead of _ and a mispelled !is_archives() instead of !is_archive()
the background colours of the theme (this-just-in) had disappeared, very strange anyway i digress cheers
Hello,
I have activated the Widget Logic AND TTF Title plugins in the hopes of replacing widget titles with images.
I’ve been at it for days but just can’t seem to get it no matter what snippet I try (or where I try to put it).
I am using the 2010 Weaver theme.
http://www.homestilo.com is the site.
ANY help/insight would be much appreciated!!
Have you put the example code on http://wordpress.org/extend/plugins/widget-logic/other_notes/ in your theme’s functions.php file?
Hi Alan,
I have tried that. I have activated the ‘widget_content’ filter. I have also tried activating the ‘wp_reset_query’ fix.
I have tried putting the example code into the functions.php file, also a 2010functions.php file that is there AND a section that the theme has for pasting snippets.
The theme is a child theme of Twenty Ten.I thought that may be a reason why it isn’t working. So I tried activating Twenty Ten and placing into that functions.php file. Nada. I’m stumped.
the wp_reset_query option is not relevant here – so forget that.
the add_filter line and ttftext_widget_title function need putting in just once in the theme’s functions.php file – if you have it multiple times you will probablt end up with errors.
troubleshooting steps you could try that I can think of.
first check ttftitles is working ok. put
the_ttftext( “test text”, true )
somewhere in your theme’s php, or in a php widget perhaps. that will output a gif of ‘test text’ in the default style.
if that’s OK, then change the widget content filter to something more basic like:
function ttftext_widget_title($content=”)
{ return “WIDGET CONTENT FILTER IS WORKING”.$content;
}
to add that text before every widget. Also just to check you are using actual widgets – not the theme’s default sidebar appearances – the widget_content filter only works on the widgets you configure in admin ‘appearance > widgets’
if none of that helps, i don’t know what else I could offer other than to get stuck in to your server myself.
Hello Again,
In the end it was so simple I could kick myself. Basically, it was the code that you suggest all along. BUT I had to replace wherever it read h2 to read h3.
Thanks again for all the help and the great plugin!
ha ha! yes that would do it! i should add a note to the effect that you need to adapt that code to the specifics of your theme. cheers, and i’m glad it worked out for you.
A
Hi, I want a widget to show up on a specific page. So i wrote is_page(‘About’). But it still shows up on every page. What am I missing?
Thanks!
I found something about wp_head(), that it would be necessary in the header of the theme. All true, i added it to the code, just before the /head-tag, and it all works fine now!
Awesome widget, thanks!
erro:
Fatal error: Cannot redeclare wl_charity() (previously declared in /home/travesse/public_html/wp-content/themes/columbia/functions/plugins/widget-logic/widget_logic.php:15) in /home/travesse/public_html/wp-content/plugins/widget-logic/widget_logic.php on line 19
I can’t say for sure, but your error indicates that your active theme ‘columbia’ appears to have bundled widget logic inside it – so activating WL separately is redundant and bound to cause conflicts.
must see about that bundling…
I would like posts that are in_category(‘x’) to show up on one specific page: is_page(‘y’). So in the Recent Posts widget I have entered widget logic that says: is_page(‘y’) && in_category(‘x’). And the widget does not show up. There is a post in that category. When I remove && in_category(‘x’) and only have is_page(‘y’), then the widget shows up only on that page and showing all recent posts. in_category(‘x’) by itself does not show any recent posts.
I must be missing something really simple, but cannot see it. I’d appreciate any direction.
Love the plugin!
WL is not able to filter the content of Recent Posts for you – that’s the basic misunderstanding. it is just able to show a widget or not depending on the logic you give it.
is_page(‘y’) && in_category(‘x’)
is not going to show anywhere because it will only show when you are showing page Y and a post in category X – which can’t be true at the same time. (at least i can’t think of a way)
With debugging on I get the error:
Notice: Undefined index: callback_wl_redirect in
“wordpress/wp-content/plugins/widget-logic/widget_logic.php on line 137”
No matter what theme I use
Upgrade you lazy mother fucker!
I am looking to find a way to possibly use your plugin to help me with pages I have missed. I have used your plugin on a lot of pages, but for all the pages I havent used it on, I wanted to use a widget to post something if that makes sense. Basically I want to know if there is a way to say “every page that doesnt have something in the sidebar, put this in there”. Is this possible?
This plugin is working except for the page with the articles. I’ve made static the home page and the page with the articles (in the admin/reading).
I can’t show a widget only for the page with the articles. I’ve tried with the id, the name … .
Have you any idea please ? Thanks a lot
Perhaps I have my head firmly planted where the sun don’t shine, but for the life of me I can’t get the Widget Logic plugin to show up on my site. I’ve trashed it and reloaded it. It shows up in my list of plugins as active. But nowhere does it appear in the dashboard or in plugins to drag and drop to a sidebar widget. I’m using the Platform Theme, but from what i can tell others with that them are using Widget Logic. Am I missing something in the way to access the plugin for use?
Hello, I try use the “Relocate Upload” and is not compatible with current WordPress Version. Will you release update for this plugin?
Thanks
Willy
Figured it out. The widget appears when you post the link itself, but I had another widget blocking it. Now I not only got it up and running correctly, I find it to be a dynomite widget for mixing up affiliate ads on my site. Check it out at http://www.endzonestore.com.
I have content in the primary widget showing on my home page and have used widget logic to show secondary widget content on other pages and not on the home page. However a part of the secondary widget is showing on the home page. I have used css to style both widgets.
Do you know what could be happening here?
Thanks, widget logic is simple used by all the people
Hello. Im using Widget Logic and the TEXT widget to load images in my sidebar. I am basing the widget loading off of categories:
in_category( array( ‘lofts-and-multi-family’,’retail’,’office’ ) )
The issue is, some posts contain more than one category, like ‘retail’ and ‘office’ for navigation. Since it has multiple categories, widget logic is loading multiple TEXT widgets on the page. How can tell Widget Logic to only load one (the first category would be best).
thanks for your help
Wow, pretty cool plugins you have there, so far I have only 5 plugins on your list that are installed in my WP blog, I think I’m gonna explore the rest of your list and see how it works, thanks a lot for this.
Widget logic made an ugly white bar appear on my site.
When scrolling it’s particularly noticeable.
I’ve had your plugin installed for over a year. I have not added or deleted any plugins. All I did was updated to wp 3.2.1 and now I am getting this error:
Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ‘)’ in /home/ckwebsys/public_html/wp-content/plugins/widget-logic/widget_logic.php(161) : eval()’d code on line 1
website is http://www.ckwebsystems.com
this is what is on line 157 – 161
// before we execute the condtional code, perhaps we want to wp_reset_query…
if ( !empty( $wl_options[‘widget_logic-options-wp_reset_query’] ) && ( $wl_options[‘widget_logic-options-wp_reset_query’] == ‘checked’ ) && empty( $wp_reset_query_is_done ) )
{ wp_reset_query(); $wp_reset_query_is_done=true;}
$wl_value=(eval($wl_value) && is_callable($callback));
it’s the eval’ing of your widget logic that’s throwing the error – perhaps a missing end bracket? definitely worth a look if you’ve changed the widget logic recently
This excellent website rocks !. I regularly discovered something new & unique listed here. I appreciate you for that data.
Great website. The posts are good and informative.
This plug-in is a godsend.I’m going to your donation link now!
newbie. i installed the widget to make sidebars not appear..
how do i so that?where do i go?
Hi
Thanks for the great plugin. However I have a question. I’m trying to put up a widget using conditional tags in a theme where I use custom post types. For some reason it doesn’t seem to work. I tried multiple combinations
Usually for category 33 I would use is_category(’33’). I tried is_video_category(’33’) (which is the custom post template) but that brings back a fatal error so it’s not that. Any ideas?
Thank you
Thanks for the plugins, I’ll add them to my lists.
thank you for the helpfull plugin;) i am using it for my blog gehaktballen maken
Not sure if this is an issue or not but when I use
!is_search() || !is_404()
widgets appear on both Search and 404 pages. Though, if I use
!is_search() && !is_404()
widgets do not appear on either of the 404 or Search pages. Weird, no?
no, not weird! that’s exactly right.
the first one, not search OR not 404, will ALWAYS be true on every page (will only be true if a page is both 404 and search!)
the second one, not search AND not 404, will only be true when the page is not a 404 and not a search.
Hello,
Please could you help me with something, as I find it quite confusion.
OK, so I don’t want a widget to appear in a certain category… I have done that successfully with the following:
!is_category(19)
But obviously that is only for the “category”… This does not apply to the “posts” within that category.
What would be the complete code to block the widget within both the category and every post in that particular category?
Thank you.
you are after a !’d variation on the “How do I get a widget to appear both on a category page and on single posts within that category?” in the FAQ
http://wordpress.org/extend/plugins/widget-logic/faq/
Hi Freaky Trigger,
I have widget logic running and love it, it works a treat. But I am stumped for a tag for the homepage. The home page dose not seem to have a name or tag, could you suggest a tag that will keep one of my widgets form showing on the homepage please?
Many thanks,
Simon.
@Simon Booton-Mander – use the following:
!is_front_page()
will show the targeted widget everywhere but the designated home page (or front page setting of the WP site).
hth.
I have a question. How to I target a page that I setup in wp to display my blog posts. I have a page for that and a specific page for my home page. I tried both is_post() and is_page() with the page id and the slug, neither of which seemed to work.
Thanks!
http://codex.wordpress.org/Conditional_Tags#The_Main_Page
I updated Widget Logic this morning and my site immediately started giving a 500 internal server error. Had to remove it manually. Site OK again now. Would love to use the plugin but it’s causing problems!
try again – it might have been a partial download or something. i’ve had about 5000 downloads (of the recent 0.51 update) so far, and most people are feeding back positively.
Hi I have the following show up on my sidebar:
Primary Sidebar Widget Area
This is the Primary Sidebar Widget Area. You can add content to this area by visiting your Widgets Panel and adding new widgets to this area.
I have the following formula on the widgets I don’t want appearing: !is_page( array ( ‘Find a Spa’, ‘Find a Class’, ‘Find Yoga’, ‘Get a Facial’, ‘Get a Massage’, ‘Editorial Calendar’, ‘Spas Near You’ ) )
Please advise what I should do to have the widgets not appear. Thank you.
The page: http://spadora.net/yoga/
by the sound of it no widgets are appearing. it is common for a theme to have default text when there are no widgets, and in this case the “This is the Primary Sidebar Widget Area…” text is that default text.
If you want rid of that text your options are to alter the theme or to make a single widget appear – one that might be minimal in content/appearance
I am having the same problem on my site. How do you alter the theme to get rid of that text especially if my text is not showing up there?
I’m perplexed. I’ve successfully used your great plugin up until now. No problems. I updated today and not only did all my widgets disappear (including those that were inactive and required editing) but all of my sidebars and new widget areas that I created. It’s not the theme (atahualpa). Is this an example of fixing something that (to me anyway) wasn’t broken? Please, what’s the solution?
BTW, I’m really not a php person, which is why your plugin is so great. It makes a great deal easier. I appreciate the fact that it’s free, but this really is not a complaint, it’s an observation. If I need to use code to correct the problem, doesn’t that defeat the purpose of the ease and simplicity of the plugin?
I think I’ve got it working now.
Hi
I’m trying to get the weather widget to only appear on the home page of my wordpress site http://moti.org/blog/
I have installed the widget logic plugin so that I can choose the pages that widgets appear on. This works just fine for all the other widgets except for the weather widget.
What happens is that when I fill in the widget logic box for the weather widget and press update the instruction just disappears. Consequently the meteo appears on every page with a sidebar which is not what I want. I think there must be a conflict or a bug somewhere.
Can you help with a simple solution?
Many thanks
Penelope
On the off chance that Braudis, looks back in, it would be great if you could sketch out what went wrong, in case anyone else sees something similar. It’s not something that the code update should have caused.
Penelope, i’d have to look at the widget you are using. If it’s http://wordpress.org/extend/plugins/weather-widget/ i’ll have a quick look soon
Hi – thanks for getting back to me
The weather widget is GoGadget Weather and Weatherforecast Widget.
I used this one because it comes in French and the weather underground forecast for Agen(our local town), France is always very accurate.
I am using an artisteer generated design for the site.
I installed the wigit logic widget and then the goGadgetweather widget and several others including text widgets to appear in the sidebar. Widget logic works for the others but not for the weather one.I fill in the options for the weather widget and then the logic box with
is_page(‘home’)
just like the others then when I press save it disappears – poouf!
I tried everything reinstalling, re-activating ticking and unticking the widget logic boxes at the bottom etc but nothing worked, however I have found a temporary solution.
Following the instructions in the GoGadget manual I activated a shortcode plugin for the weather widget and put it in a text widget. The widget logic code does work with text widgets so I was able to program it to only show on the home page. This is working for now, but it would be nice to have it working properly.
If you send me an e-mail I will send you the login so you can have a look for yourself.
Many thanks
Penelope
Hello,
i find this to be the best plugin out there of its type. And find it very handy to use the short space we have for widgets.
Regards
I am having a nightmare with mine. http://www.egypttodaytravel.com and could really do with advice. I have placed some graphic widgets on my sidebars and they are great when on the home page or on the other “pages” pages. But if they land on a category I get a big brown box that is actually going over my tour summary boxes (from the transfers and transport widget) and falling off the page on the right hand sidebar (for the other widgets). I dont know what I am doing wrong. If I put is_home_page() it disappears, i have tried is_front_page() and I have even tried taking it off the category pages by using !is_category(). Nothing works. I either lose it completely from the home page or if I dont put anything in the logic then it is fine on the home page but the problem comes back into the category pages i.e. 01 Day Tours for example you will see the brown box comes back up. Can anyone help?
Eileen, your problem appears to be a CSS problem. your home page BODY tag has a simple class of “home blog” but the category pages BODY class is (e.g.) “archive category category-01-day-egypt-tours category-57 parent-category-tours-of-egypt” which is very different and the result is different CSS rules get applied.
Hi Alan, thanks for getting back to me. I have absolutely no web design experience at all, our web designer put all the main bits on the website but has failed to respond to me in over a week to try to resolve this problem. And now I’m trying to fix it myself :-) what do I do then to only have the widgets on the home page? or even if its possible on the home page and on the other pages rather than the category ones? most importantly it is the home page I really need them on. But ideally if I could have them on the other pages except for the actual tours or tour summaries. thanks for your help so far Alan xx
Alan, also for example on the individual tours this sidebar is over-writing the key information on the tours too…
http://www.egypttodaytravel.com/index.php/2012/01/tours-of-egypt/abu-simbel-sun-festival-7-nights-tour-programme-including-nile-cruise/ and so I need to take them off there also.
Thanks again, Eileen xx
you mentioned trying is_front_page(), but not is_home() so try that
http://codex.wordpress.org/Conditional_Tags#The_Main_Page
Alan! you are my hero!
First of all when I did is_home() it didnt work, it took itcompletely off the home page as well, and I had tried it before and the same thing had happened. However this time I did it again following your advice but also I checked the box …. Use ‘wp_reset_query’ fix [save] and WOOHHOOO it worked! I cant thank you enough Alan.
I have also tried putting or is_page() but that takes it off the home page as well again, so I will not push my luck any more :-) I am just delighted that at least I got it on the home page and I can play around with it further later on. For now, it has definately fixed the problem.
I am so so glad I found this site, you are all fantastic to help us all out like this.
Well done freaky trigger!! I am going to make a donation right now.
And Alan! I cannot thank you enough.
Have a brill weekend!
Eileen xxx
Thanks for the donation!
kalki story
How do I add widgets on multiple pages? I wanted to have it on is_front_page() and also on other page?
You can use || between 2 tests to check if either test A or test B are true, e.g. is_front_page() || is_author(‘alan’)
http://wordpress.org/extend/plugins/widget-logic/other_notes/
Just upgraded to Widget logic version 0.51 and suddenly we have ‘META’ and ‘ARCHIVES’ on our home page — but nothing like these in our widgets – how do we hide these? where did they come from?
Solved with adding a blank text widget with blank ‘Widget logic’ to our sidebar then they go away – is it possible version 0.51 now somehow adds a default ‘META’ and ‘ARCHIVES’ when no widgets set on the home page..?!
P.S. we hide our widgets from certain pages using ‘Widget logic’ !is_page( array( 188, 282 ) )
Not quite. Your theme has default sidebar contents when there are no widgets. The new WL code properly tells WP when there are no widgets so this default content appears. Gonna add this to the FAQ when I (finally) get round to the ‘late loading’ extra coding I promised weeks ago :-(
Nice Work. This Plugins Too Good To Be Forgotten like a cup of Coffee in the morning. I love This. By the way, Coffee has a time guys.
Thanks…
Thank for this useful plugin. Anyway how can I post a sidebar on selected multiple pages only?
Good morning, I’m Spanish, sorry if my English is not good.
I have 3 days with a problem to make something very simple.
I want a widget to display only the file index.php, but repeats the widget at: /page2/ & /page/3/ & /page/4/ & /page/5/ and so indefinitely.
Any solution?.
Thank you.
i am struggling to get a plugin that can act as a filter to filter my site for price and certain tags. I dont know how i can do that. Please can you reply
I’m afraid you are going to have to expand on that description, tony.
After the last update, I can’t upload pictures on my blog anymore. I don’t know why, it says “HTTP Error” after I wait a wile and nothing happens. If I Deactivate the plugin, it’s ok.
Knows anyone why?
P.S.: I’ve noticed this issue on two different blogs hosted in two different places.
You’ve got me there – I have absolutely no idea, sorry. And I can’t think of a way of helping you troubleshoot, short of giving me admin access to a site displaying this behaviour.
could it be that some of your logic outputs text? try removing the widget logic from widgets one by one to see if blanking one of them stops this from happening – you can always save out your current WL config for safe keeping.
May Day! May Day!
We recently learned that the IDXpress plugin by Diverse Solutions does not function properly when WL is activated. This is a really tough spot to be in because our site relies so heavily on both widgets that it simply cannot do without one or the other. The IDXpress plugin is a dynamic real estate mls/property search tool that works perfectly when the WL widget is inactivated. However, when WL is activated, the property slide show component of the plugin fails to work.
Your plugin is simply a must have for anyone that uses WordPress and I so hope that you might have some guidance for us.
Here’s an example page: http://califund[dot com]/idx/mls-p820512-359_mountain_ct_brea_ca_92821
Thanks in advance for any help you might be willing to offer.
I assume that as the slideshow in that page linked works, that you have deactivated WL. I’d need to see what it and the HTML looks like when WL is active to guess at the problem
Never had a problem with widgets now there is a delay when using and when I take blank widget to use most times I have to click on widgets again to use another one because it is greyed out any help thank you
getting errors on v 0.52:
Parse error: syntax error, unexpected ‘;’ in /home/jinga/public_html/system67/wp-content/plugins/widget-logic/widget_logic.php(270) : eval()’d code on line 1
something is wrong with the code in your widget-specific “widget logic”
Thank for this useful plugin. I think I’ve got it working now :-)
I recently installed Widget Logic and love it for the customized landing page I created.
My only problem is that my sidebar disappears on my regular blog posts. Here are a few samples. Any help you can give is appreciated.
when I created a new post, my homepage sidebar does not show up. Here are the three links:
Homepage
http://www.joeyo.org
Custom Side Column (page)
http://www.joeyo.org/create-transforming-stories-of-art-life-faith/
Latest Post (Side column not showing)
http://www.joeyo.org/2012/05/a-video-interview-with-eric-nykamp/
Also, I’m not sure if this is a WordPress issue or Widget Logic, but ever since I started using WL, my two most recent posts are showing up in the #2 & #3 position and my older post remains at #1 (Eric Nykamp post).
Thanks for your input!
The new wordpress upgrades have left this plugin and my site a bit wonky. For now the plugin is disabled but this is the error header thing it’s causing: http://s45.photobucket.com/albums/f60/Talinan/?action=view¤t=ScreenShot2012-06-15at122418PM.png
Any idea what I can do to fix this?
“parse error…eval()’d” indicates you have badly formed widget logic code in one of your widgets. 2 errors suggests two different widgets have similar problems. you can work out where the problem is by blanking (and later restoring) the logic and seeing if it makes a difference
@joey #448, looks like you home is fine, so I’m going to guess you fixed it?
I have used widget logic for over three months on a development site.and i am very pleased with it. I uploaded to 0.52 and immediately Nextgen galleries could not locate either galleries or pictures.
It came the same day i upgraded word press 3.4.1and suffusion 4.2.4 so i was not sure of the underlying cause
After a bit of testing i was able to switch the error in Nextgen on and off simply by loading unloading Widget Logic.?
Any thoughts
i am trying to think what difference deactivating and reactivating WL would make? I’m afraid I don’t know enough about nextgen galleries to know at what level WL could be interfering.
One new thing to try is the ‘Load logic’ setting which sets the point that WL starts to be checked – if you set it from the default ‘early as possible’ to a later point, see what difference that makes. Of course, you are all set now (for whatever odd reason!), but for next time. Glad you are ok tho.
Hi there!
First of all, nice job i found Widget Logic very useful.
Thank you!
Second, i am using it on website based on wordpress 2.9.2 that i am not going to update to an newer version.
I never had any kind of problem before, but today casually i found an error message under admin panel / widget section.
I wasn’t able to expand any of the sidebars in this section there in the admin section. The website works well anyway.
Fatal error: Call to undefined function submit_button() in …/wp-content/plugins/widget-logic/widget_logic.php on line 194
And this is the line:
\< ?php submit_button( __( 'Save WL options' ), 'button-primary', 'widget_logic-options-submit', false ); ?\>
Now i need to make some changes to this website especially on widgets so i’m gonna asking you: what might have happened? And how can i fix that?
Thank you
Piero
Ah thanks for that. Turns out submit_button is WP 3.1 and later, and I never noticed. I might revert that to make it 2.8 compatible. someone else said it wasn’t worked pre 3.0, and i was most put out, but they gave me no more clues. I will have a tinker.
you can fix it in the short term by reverting to an older version
http://wordpress.org/extend/plugins/widget-logic/developers/
error in 0.53
see: http://wordpress.org/support/topic/plugin-widget-logic-problem-after-upgrading-to-053?replies=7#post-2983754
Hi your plugin widget login has a upgrade to day I did it and now it does not activate and i received this message
Fatal error: Can’t use function return value in write context in /home/offshore/public_html/wp-content/plugins/widget-logic/widget_logic.php on line 264
You know what happen?
Rene
Apologies to the many people who updated to the accidentally prematurely released 0.53 I’ve been trialling. I rolled back the WP repository ‘stable version’ to 0.52 as soon as the problem was brought to my attention.
i’m afraid you will have to manually remove WL to make your site function again and then reinstall the properly stable 0.52
0.53 will be out soon to fix what are relatively minor bugs, so it’s rubbish that i’ve caused so much badness in the process :-(
please help on this issue, i have used widget logic for years, suddenly on my artisteer created theme, i enter my conditional tag into the widget “twitter widget” and the widget “diy tarot” and on pressing save the conditional tag disappears. it is working fine on the other text widgets. i have also deactivated all other plugins, same issue, i have further placed the conditional statement recomended by you at the end of the loop. no solution. funnily, on other blogs also using artisteer theme the twitter widget accepts the conditional tag. i have also updated deactivated and reactivated the problem plugins. thanks in advance. tamsin
“the conditional statement recomended by you at the end of the loop”
sorry, Misty, what is that you are referring to there. I’ve no clue why some widgets should lose their WL on saving – i’ve even looked at http://wordpress.org/extend/plugins/diy-tarot/ and it seems harmless enough. sorry
Alan,
Before I had just deactivated the plugin. It’s active now and still has the error in the header, twice.
http://www.harvestofdailylife.com/seriously-an-electric-toothbrush-turned-this-mouth-snob-around-ad/
Funny thing is it’s always worked fine before… then in June after some WP upgrades it got wonky.
Gah, can’t edit the previous comment anymore but the PHP in one of my widget had improper spaces and junk. Fixed it and the problem is resolved :) Yippie.
Just FYI, if you accidentally enter a line break into a widget’s “widget logic” field, it breaks the plugin and puts a lot of error codes all over your site. When the plugins page is refreshed, the line break disappears from the widget logic field, making it really difficult to determine the cause of the error (trust me). If you save the widget again, without the line break in the widget logic field, the error is gone.
Thanks steve – i will check and add that to my to do list. I have been very poor at updates for ages now – ust try harder
Hi,
The plugin is great. I need some help, the sidebar is not picking a the standard width. How do I change the width size?
Here the link http://dev.myhavens.com/latest-technology-news-and-update/
Please help!
Widget Logic is one of the must have plugins when it comes to WordPress. I use it pretty much for every site I create. However, there have been some compatibility issues in the recent WP 3.5, I hope Alan will have some time to do needed modifications.
Installed Widget Logic just now, and it saved my day! Thank you so much for the brilliant piece of work! This is definitely one of the “must-have” wordpress plugins. Thank you again! :)
Plug-in is very important for word-press. I want to add this plug-in my word-press anybody help me. How possible this work.
Thank you Benny
Hello, it is Widget Logic plug-in working on WordPress 3.8.1 ?
yes. i’ll update the compatible version ID soon
Wow, high praise and from Google no less…
Wow, what a supportive website incredibly uncle to new users and whatnot.
Actually, more seriously, I did wonder about if you (or someone) could have a separate linkawidget to have the “Latest Message” sidecar on its own? I often link to the “Popular” front page, and have to scroll down several wonderful Number Ones to get to the bottom, and often on flicking find I have pressed too hard and now I have the initial view of The Tampera, andhave to start over..
Right now it sounds liie BlogEngine is the best blogging platform out there right now.
(from what I’ve read) Is that what you are using on your blog?
Hello my friend! I want to say that this article is amazing, great written and come with approximately all significant infos.
I’d likke to look more posts like this .
Very good post! We will be linking to this particularly great article on our site.
Keep up the great writing.
‘ We ensure that our residents get three healthy, nutritious meals daily that are cooked home style for flavor and
served restaurant style for the residents’ convenience.
Taking care of the elderly is an issue that almost all families
face. Some of them are listed below: Professional cleaning: as the name suggests,
the cleaning task of the place is done by experts
and professionals.
*Doesn’t Help Thee Community: As you will see below, donating a non-running vehicle does
quite a bitt to help the community. Some people also opt for another smarter way of getting rid of their
old cars. The first step is to determine tthe value of the carr
in the market.
Not for used car parts as had been recently listed.
Some SUV’s andd larger trucks can command a greater top quality.
Their representatives are well experienced and after taking a
look at the car, they would quote the best possible
price for it.
Hello there, I hope you are doing well. First I would like to thank you for writing such a great widget. I installed it in hopes of making life easier for my client, well ok, and myself during development LOL.
I am using the Avada theme on the latest WordPress but cannot for the life of me get it to show no matter what I use.
I tried this
is_category(19,11,10,12) || (is_single() && in_category(19,11,10,12))
so if it is one of those categories, or a post within one of those categories, then that given widget would work, but still nothing.
:(
I did post over on the plugin support page but nobody there seems to be able to help
Thankies
Tanya
I don’t mean to bug, but is there any solution to my problem?
Thankies
Tanya
Would I get a quicker reply if I offered to pay for help?
is_category(19,11,10,12) || (is_single() && in_category(19,11,10,12))
that will work as you expect. try it on another plain WP theme first
then it might be your theme is interfering with things. you can get round this with some of “Widget Logic” options in the widget admin screen. Try a late “Load logic” point or the reset_query fix
During the preliminary hearings at the City Council it became apparent that Schitzer doesn’t want to talk about just how
profitable iit really is. Even if yyou never achieve material
wealth in the “real world”. Such dealerss are just a phone call away aand are ready to give a quite
on the phone instantly after knowing the condition off tthe vehicle.
Thank you Alan, I will give it a shot. Fingers crossed :)
Hi again Alan, hope you are doing well.
I must be missing something obvious. I switched to the Twenty Fifteen theme.
I added a custom menu to the default widget (default only has the search). I then added the logic to the custom menu that I added
is_category(11,10,12) || (is_single() && in_category(11,10,12))
Strange thing is, if i go to the main category of ’11′ the custom menu will show. If I go to any single posts within category ’11′ it disappears.
If I go to the others ’10′ or ’12′ it does not show at all.
Am I missing something?
:S
Thankies
Tanya
Oops, forgot to mention, once I switch to the Avada theme, none of it works. I have tried using different logic theme combinations but this thing just does not like me!
OK, kinda got it working in the avada theme, same problem though, it only shows on the first category ID# and not the rest
My brother suggested I would possibly like this website.
He was totally right. This put uup truly made my day. Youu can not
bdlieve just how a lot time I had spent for this info!
Thank you!
Hello, my site is a problem:
Parse error: syntax error, unexpected T_STRING in /home/users2/p/palmal/domains/gdknazarovo.ru/wp-content/plugins/widget-logic/widget_logic.php(314) : eval()’d code on line 1
the plugin is not edited
I read this article fully on the topic of the difference of latest and preceding technologies,
it’s remarkable article.
WOW just what I was searching for. Came here by searching for social network
My company has been using your Widget Logic plugin on our website and when activated it completely shuts the website down. Please help!
Valuable info. Lucky me I found your website by accident, and I am shocked why this accident did not happened earlier! I bookmarked it.
Major thanks for the blog article.Much thanks again. Much obliged.