One possibility would be
* save an up-to-date WP backup
* restore from an old backup when you had WL code
* save out the WL options using the new export options
* restore the DB again from the up-to-date backup
* import the WL options
You can see the new WL export/import options on the screenshots
http://ww.wp.xz.cn/extend/plugins/widget-logic/screenshots/
If save/restore is too big/slow you could delve into the SQL backup and pull out the “widget_logic” option field in wp_options table. though it will be serialised – so this might be a bit out of your “coding comfort zone”
Thanks Alan. It happened again after I made a syntax error on one of the codes. WHY is that happening? all I did was put (global $post; return (!in_array(2872,get_post_ancestors($post)));) instead of (global $post; return !(in_array(2872,get_post_ancestors($post)));)…I understand why it caused an error, but it shouldn’t have wiped out ALL the WL code. I’ve replaced all the code (again) and got the widgets showing up where I need them to again, (for the most part). Anyway, If I export the WL Options widget_logic_options.txt file, and I lose the WL code again, will that widget_logic_options.txt backup replace all the WL code where it was originally? I’m just a bit nervous about making a syntax error again.
yep, that’s a mini backup of just the WL options. I’m intrigued to track down what would lose you all your WL options though, so I tried putting in
global $post; return (!in_array(2872,get_post_ancestors($post)));
and it did nothing on my own install. It didn’t throw an error either. Why does this throw an error for you – it’s not obvious to me!
I have no idea. I had a few plugins that may or may not have conflicted with Widget Logic, so I removed them to avoid potential issues. Maybe it didn’t cause an error on yours because you don’t have a page ID 2872. I’m just guessing.
On the same subject, can I use a code like this>> global $post; return !(in_array(‘addiction-treatment-centers’,’addiction-counselors-and-therapists’,get_post_ancestors($post)));
What I’m trying to accomplish is, I do not want the Adsense ads in the footer widget NOT to appear in those pages, or their child pages
REV: What I’m trying to accomplish is, I want the Adsense ads in the footer widget NOT to appear in those pages, or their child pages
no that’s not going to work, as in_array’s first parameter is a single value, and the 2nd is an array to look through. get_post_ancestors returns the array to check.
http://codex.ww.wp.xz.cn/Function_Reference/get_post_ancestors
You’ll have to try something like
global $post; $ancestors= get_post_ancestors($post); return !in_array(‘addiction-treatment-centers’,$ancestors) && !in_array(‘addiction-counselors-and-therapists’,$ancestors);
Can I ask, upthread you said “I understand why it caused an error”, but I can’t see why. Perhaps if you explain that, it might make something else clear that caused this.
global $post; $ancestors= get_post_ancestors($post); return !in_array(‘addiction-treatment-centers’,$ancestors) && !in_array(‘addiction-counselors-and-therapists’,$ancestors);
(This code does not work for what I am trying to accomplish. The widget content still shows up on all those pages.) Neither does >> global $post; $ancestors= get_post_ancestors($post); return !in_array(‘addiction-treatment-centers’,$ancestors) || !in_array(‘addiction-counselors-and-therapists’,$ancestors);