2
votes

I have a really strange problem with Wordpress and I don't know what's going on.

I have a static home page called front-page.php which holds the front page content and this displays on the front page.

I also have a news page which i understand uses home.php and that all seems to work properly.

The problem lies with my footer.php. I have put a conditional statement in there to determine if i'm on the front page or the news page.

<?php if( is_front_page() ): ?>
// do something
<?php elseif( is_home() ): ?>
// do something else
<?php else; ?>
// do something else
<?php endif; ?>

What it does and i don't know why is that when on the front page, it ignores if( is_front_page() ) because it returns false for some reason then is goes through elseif( is_home() ) becuase that returns true for some reason.

Under Settings > Reading I've set the front page to display a static page and the posts page is my news page.

Under Appearance > Customize I've done the same.

I just don't understand why it display the content how i expect but not the footer

UPDATE:

I found out what is causing the problem. It's the code the displays the latest 4 posts on the static front page. I've commented it out but how can i display them and still have the front page and new page use a different footer?

<?php get_header(); ?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    <?php the_content(); ?>

<?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<div class="container">
<div class="row">
<div class="span12 span-home-news">
<div class="latest-news">
<h1>Latest News</h1>
<?php
    /*$cat_name = "news";
    $catID = get_cat_ID($cat_name);
    query_posts('showposts=4&cat='.$catID);
    $counter = 0;
    while(have_posts()): the_post(); ?>
    <div class="display-posts-listing">
        <?php echo get_the_post_thumbnail($post_id, 'thumbnail', array('class' => 'alignleft')); ?>
        <h2><a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a></h2>
        <p><strong><?php echo get_the_date( 'j F Y' ); ?></strong></p>
        <p><?php echo excerpt(20); ?></p>
        <p><a class="global-blue-button" href="<?php echo get_permalink(); ?>"><span>Read more...</span></a></p>
    </div>
    <?php $counter++; if($counter%2 == 0): ?>
    <div style="clear: both;"></div>
    <?php endif; endwhile;  */?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>
<?php wp_footer(); ?>
1

1 Answers

2
votes

Try running wp_reset_query() after your loop (after the endwhile;).

wp_reset_query() resets the query data and restores the original query. After you run wp_reset_query() Wordpress should recognise that you are on the home page.