Forums

Widget Logic- Page Template not working (8 posts)

  1. blueyonder
    Member
    Posted 4 months ago #

    I installed Widget Logic and it works great for almost everything. The only problem I am having is that for some reason it won't exclude a widget on a page that I am using a particular template on. I have the following code:

    !is_page(array(144,174,146,208)

    It works for all of the pages except for page 146. I am using a template on that page that calls certain posts in a particular category:

    <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=10&showposts=5&paged=$page");
    ?>

    The weird thing is that I am using the code:

    is_page(array(144,174,146,208)

    for another widget that I want to only show up on those pages and it works fine.

    Any ideas why I can't exclude the widget from that page?

    Thanks!

  2. alanft
    Member
    Posted 4 months ago #

    some possible things to try that might shed some light:

    what happens if you narrow down the logic to just !is_page(146) for widget A and is_page(146) for widget B?

    what happens if you don't use that code in the template?

    does the 'wp_reset_query' option have any effect?

  3. blueyonder
    Member
    Posted 4 months ago #

    !is_page(146) still doesn't work :(

    It does work if I remove the code from the page template, but I really need that code in there. Hmmm...

  4. greenshady
    Member
    Posted 4 months ago #

    Add this at the end of your template (before the call to your widget area):

    <?php wp_reset_query(); ?>

    Basically, your query is probably telling WP that you're on a category archive rather than a page, so you need to reset it.

  5. alanft
    Member
    Posted 4 months ago #

    i would love to know if the 'wp_reset_query' option (at the foot of the widget admin page) has any effect. it *should* have the same effect as greenshady's suggestion.

  6. blueyonder
    Member
    Posted 4 months ago #

    Thanks Greenshady! That worked.

    The weird thing is that the 'wp_reset_query' option (at the foot of the widget admin page) didn't work, but it did work once I added it to my page template.

    Thanks both of you for all your help!!!

  7. alanft
    Member
    Posted 4 months ago #

    ok thanks. looks like i could do with checking out how well that option is working cos it's meant to deal with exactly that sort of coding issue.

    cheers

  8. blueyonder
    Member
    Posted 4 months ago #

    Oh. I was wrong.

    Adding <?php wp_reset_query(); ?> woorked, but it reset the page so that my other code` <?php
    $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=10&showposts=5&paged=$page");
    ?>` didn't work :(

    I guess I can't have both?

Reply

You must log in to post.

About this Topic