1

i am trying to add the below code in an ajax wordpress theme in order to show a div only in front page

<?php wp_reset_query(); ?>
<?php if(is_home() || is_front_page()): ?>
 <!-- Do the things here... -->
<?php else: ?>
 <!-- Else part goes here...  -->
<?php endif;  ?>

unfortonatly it doesnt work when accessing from menu to other pages for example :

HOME-->SECOND PAGE--> THIRD PAGE

it works only if i access direct to an other page : for example :

www.example.com/secondpage

do you know any solution on this ?

4

1 回答 1

0

Check this article on how to properly use is_front_page and is_home functions.

Basically you should use this code:

if ( is_front_page() && is_home() ){
    // Default homepage
} elseif ( is_front_page()){
    //Static homepage
} elseif ( is_home()){
    //Blog page
} else {
    //everything else
}
于 2013-04-13T19:23:54.927 回答