• Resolved Zambrano Sergio

    (@sergiozambrano)


    I can’t get to work my is_page(‘contact’) conditional. It ALWAYS return false.

    I’ve put it in the footer.php to show the slide-in contact form on any page OTHER than “Contact” page https://seosumo.com/contact since that page already contains a contact form.

    This is my code
    <?php if (!is_page(‘Contact’)) {
    include(TEMPLATEPATH.’/sideform.php’);
    } ?>

    I’ve tried with the following no success:
    -lowercase (as the url shows) ‘contact’
    -different if arrangements (if(foo)) :
    -page ID instead of name.
    -is_page() combined with else instead of !is_page()
    -is_page() conditional placed on the page’s template instead of footer.

    Nothing worked, so my questions are:
    1) Does is_page() need the page to show 1 page only? no extra loops? (mine loads blog posts in that page too)

    2) Does is_page() need to be called from within the loop?

    WP version is 2.7.1

    Any ideas?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Using a just installed 2.7.1 blog and the WordPress Default theme, and putting this in the wp-content/themes/default/footer.php

    <?php if (is_page('About')) {
    echo 'this is page 2';
    }
    ?>

    Does cause ‘this is page 2’ to be displayed ONLY when viewing the About page.

    Thread Starter Zambrano Sergio

    (@sergiozambrano)

    SOLVED:

    When using multiple loops, the is_page(‘Somepage’) doesn’t work.

    I just added wp_reset_query() and it works like a charm.

    <?php wp_reset_query();
    if (!is_page(‘Contact’)) {
    include(TEMPLATEPATH.’/sideform.php’);
    }
    ?>

    I don’t know the extent of the issue, or which of the commands/variables of the secondary loop caused this, but resetting the query worked.

    I hope someone have the specific reason of this, so we can play around the code more freely.

    wp_reset_query(); works great to solve problems ??

    rcain

    (@rcain)

    thanks for posting Sergio – solved my exact same problem ??

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘is_page() needs to meet certain conditions?’ is closed to new replies.