WordPress.org

Forums

[resolved] Widget Logic on 2.8 (20 posts)

  1. alanft
    Member
    Posted 6 years ago #

    Just to announce that the current release of WL doesn't work fully on 2.8. When you hit 'Save' in a widget the AJAX way, the widget comes back without the WL field. refresh the page and it's there again (and the changes have saved??) - but it's still teh suck.

    so I have updated the code to make it work with this new bit of 2.8, and it's available as v 0.46 in the 'development version' on the versions page.

    If I don't hear anything adverse about it (say if it breaks anything important in 2.7, or there's something else new in 2.8 that i've missed) in the next couple of days, I will tag it up as an official update.

  2. doctoraa
    Member
    Posted 6 years ago #

    I've discovered that the logic can only handle simple cases such as Is_home(); anything more complex doesn't work for me. I'm trying to have a widget appear only on the home page and two other pages, but it is completely unresponsive to the "or" || operator. I haven't tried the "and" && operator. It's also not clear what number to give to a widget when some of the widgets aren't supposed to appear on every page. Can they be clashing with each other? I'm not sure if these problems are due to the upgrade to 2.8 since I never tried out compound logical statements before today.

  3. Justin Tadlock
    WordPress God
    Posted 6 years ago #

    Thanks for the update. I recommend this to pretty much all my theme users, and I'll let them know an update will be ready soon.

  4. alanft
    Member
    Posted 6 years ago #

    doctoraa. give me an example of a complex case that isn't working. Also "what number to give to a widget". Where do you give numbers to a widget?

    (if you mean the order in the sidebar in the non-javascript admin interface, it's the order of the widgets regardless of whether they appear.)

    greenshady - it would be great if you could try out the 'dev' version and let me know what you think.

    cheers all.

  5. Justin Tadlock
    WordPress God
    Posted 6 years ago #

    @alanft

    Will do just as soon as I wake up tomorrow.

  6. demetris
    Member
    Posted 6 years ago #

    @alanft: Thanks for the update. I’m currently testing it on 2.8 with one widget and a condition like this:

    is_singular() && in_category('foo') && in_category('bar')

    ... and it seems to work fine.

  7. doctoraa
    Member
    Posted 6 years ago #

    Here's an example of a complex statement that I haven't had any success with:

    is_home() || is_page('Page One') || is_page('Page Two')

    I also tried

    (is_home() || is_page('Page One') || is_page('Page Two'))

    and

    (is_home()) || (is_page('Page One')) || (is_page('Page Two'))

    In each case, the widget only appeared on the home page. Maybe I am misuing the syntax; clearly, it is not reacting to the || symbols.

    With the numbering scheme, if I have three widgets in Sidebar 1 on the homepage, but I only want the first two plus a new one on Page One, would I rank the new widget as 3 or 4 in Sidebar 1? I tried both with no success.

  8. doctoraa
    Member
    Posted 6 years ago #

    OK, I finally discovered where the problem was. There were two screwups on my part. I was using the name that appears on the tab of each page, which is a shortened version of the actual page name. Now I see that the actual page name must be used. Also, I wasn't paying close enough attention to the case of the page name. I used upper case for the page name, but upper and lower on the tabs. The case has to match the actual page name.

    Thanks for your time, alanft!

  9. alanft
    Member
    Posted 6 years ago #

    thanks everyone.

    doctoraa, glad the logic sorted out for you in the end. wrt numbering scheme - i'm still not sure what that means - do you just mean the order of appearance in the sidebar in the admin interface?

    if you want ABC on is_home() and ABD on is_page(X), then you just define widgets ABCD with C set to appear on is_home() and D set to appear on is_page(X) with A and B defined as normal with no logic (or more complicatedly: is_home() || is_page(X))

    a couple of bonus tips wrt is_page, you can use the page ID, slug or title, and you can even give it an array of mixed IDs/slugs/titles to check against.

  10. Justin Tadlock
    WordPress God
    Posted 6 years ago #

    So far, everything seems fine to me. I've tried several different complex mixtures of tags and all has been well.

  11. alanft
    Member
    Posted 6 years ago #

    cool. it's good to know the logic is working as before.

    what was worrying me was the behaviour of the WL fields in the new 2.8 widget admin interface. I spotted just the one problem (described above) and I've fixed that. If anyone spots any other issues, holler.

    I'm going to try and test the new wp_query_reset code myself, and then I'll make the release official tomorrow I guess.

    Thanks again greenshady, and all here on the forums.

  12. alanft
    Member
    Posted 6 years ago #

    in case you hadn't noticed I did tag up 0.46 as a full release.

    I've also added a donate URL for the first time - it's a justgiving.com page to raise money for Cancer Research UK. It would be wonderful if even just a fraction of the downloads WL gets would donate 5 UKP/USD.

    Thanks to everyone again for all your feedback.

  13. dwhitedesign
    Member
    Posted 6 years ago #

    Hi Alan,

    I am having a problem that has appeared to others as well. I have a home page specified as Home (slug "home") and a blog page set as a page titled Blog (slug "blog").

    Using the is_page('blog') the widget does not appear on the blog page. I also took the approach of using:

    !is_page(home) || !is_page(about) ... etc. for the other pages

    to try and exclude the widget from pages other than the blog page but I must be doing something wrong. it does not work either.

    I have tried the page ID option too, but I am not sure I am actually using the page ID.

    Do you have any ideas why this is not working?

    ----
    WP 2.8.1
    Theme K2

  14. alanft
    Member
    Posted 6 years ago #

    read about is_home() and is_front_page() here

    http://codex.wordpress.org/Conditional_Tags#The_Main_Page

  15. zerostreet
    Member
    Posted 5 years ago #

    I've got the same issue dwhitedesign speaks of. I can add any widget to the page I have designted "Blog" when not using WL, but when using it no widget appears. I have read about home vs front page but have not had any success with that.

    Any help would be greatly appreciated!

  16. Dave333
    Member
    Posted 5 years ago #

    Just a tip for anyone who is trying to use Widget Logic only on the home page:

    I tried the is_home() to put a widget only on my home page but it never worked no matter how I tried it. The solution is to NOT use that conditional tag. Instead use this:

    is_front_page()

    That will work. WordPress seems to have a hard time determining which page is the Home page for some reason but it knows which page is the front page.

  17. Dave333
    Member
    Posted 5 years ago #

    Oh no, that will work but only if it is a single condition.

    I have other widgets that I don't want to appear on several pages including the home page so I need to find another solution. This will not work:

    !is_page(array('front_page','contact'))

    and neither will this:

    !is_page(array('home','contact'))

    and neither will this:

    !is_page(array('page-name','contact'))

    All three of those stop the widget appearing on the Contact page but none of them stop the widget appearing on the Home page.

    I guess I need to address why WordPress can't figure out which page is the home page and once it knows which is the home page, I can then use the 'home' tag.

    Anyone have any ideas?

  18. alanft
    Member
    Posted 5 years ago #

    a WP page chosen as your static front page needs the special condition is_front_page() as you worked out. if you want things to appear on that home/frontpage and another page you use

    is_front_page() || is_page('contact')

    or if you want it to appear everywhere except that

    !(is_front_page() || is_page('contact'))

  19. warwell
    Member
    Posted 5 years ago #

    How can I make a statement so that the wdiget does NOT show on a certain page OR that page's child pages? Thank you!

  20. alanft
    Member
    Posted 5 years ago #

    without testing it, try adapting the last example in the http://wordpress.org/extend/plugins/widget-logic/other_notes/ but add a ! (to make NOT). something like:

    global $post; return !(is_page(13) || ($post->post_parent=="13"));

Topic Closed

This topic has been closed to new replies.

About this Topic