WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Problem with conditional is_home, and Page Templates!!! (7 posts)

  1. taghaboy
    Member
    Posted 4 years ago #

    Hello,
    Is it normal that the is_home believe that Page Templates are the home page?

    cause is_home display the code below in every Page Templates :

    In the footer (i also try is_frontpage):

    <?php if ( is_home() ) { ?>
         my code
    <?php } ?>

    Thanks for any idea.

  2. taghaboy
    Member
    Posted 4 years ago #

    any idea, thanks

  3. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

    If the page you're looking at is set to be the home page, then yes. Otherwise, no.

  4. alchymyth
    Forum Moderator
    Posted 4 years ago #

    In the footer

    you may have used custom queries in you main section, which could have distorted the original query string and the idea of 'home' -
    try to add wp_reset_query(); before your if ( is_home() ) ..

  5. taghaboy
    Member
    Posted 4 years ago #

    try to add wp_reset_query(); before your if ( is_home() ) ..

    Magic :o , it work, if possible can you explain more, what that code do exactly?

    thanks.

  6. alchymyth
    Forum Moderator
    Posted 4 years ago #

    indeed, it seems to be a magic command; see:
    http://codex.wordpress.org/Function_Reference/wp_reset_query

  7. taghaboy
    Member
    Posted 4 years ago #

    thanks for all

Topic Closed

This topic has been closed to new replies.

About this Topic