WordPress.org

Ready to get started?Download WordPress

Forums

Widget Logic
Widget logic code disappeared - HELP PLEASE (8 posts)

  1. Mark Stevens
    Member
    Posted 2 years ago #

    The Widget logic code in ALL my widgets (164) just disappeared. The only thing I can remember doing before I noticed this was installing Extensible Widgets plugin. I didn't even get a chance to use it when I noticed every widget was showing up on every page. This is a major dilemma. I immediately removed the Extensible Widgets plugin. I tried deactivating & reactivating Widget logic (which has worked before for other simpler issues) and still no luck. Is there a way to correct this problem without re-doing hours & hours of work writing the code again? I just sent out advertising solicitation for the site and if a potential client sees this, there is no way I will get responses.
    URL is http://www.AddictionDiscussion.com - Thank you in advance!

    http://wordpress.org/extend/plugins/widget-logic/

  2. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    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://wordpress.org/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"

  3. Mark Stevens
    Member
    Posted 2 years ago #

    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.

  4. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    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!

  5. Mark Stevens
    Member
    Posted 2 years ago #

    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

  6. Mark Stevens
    Member
    Posted 2 years ago #

    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

  7. alanft
    Member
    Plugin Author

    Posted 2 years ago #

    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.wordpress.org/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.

  8. Mark Stevens
    Member
    Posted 2 years ago #

    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);

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.