So I’m kind of lost here. I have set a static front page, decalring my Home page as the front page, which uses index.php, and I have declared my static posts page as my News & Events page.
Now, whenever I make changes and try to preview my News & Events page, it is using my index.php template instead of my home.php (which I am under the impression is the default template for the static post page).
The weird thing is, whenever I navigate to the News & Events page via the actual website and not the preview, everything is showing up correctly and using the correct home.php template. So, in essence, everything is working the way I would want it to, but the fact that the preview brings me to index.php/my homepage (even though the URL shows I am supposed to be previewing the right page ID), has me concerned.
HERE is my index.php
<?php get_header(); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, this page does not exist.'); ?></p>
<?php endif; ?>
<?php get_footer(); ?>
HERE is my home.php
<?php get_header(); ?>
<section id="news">
<div class="row">
<div class="container">
<div class="col-md-8">
<h1 style="margin-bottom:50px">News and Events</h1>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<p><em><?php the_time('l, F jS, Y'); ?></em></p>
<p>Category: <?php the_category(', ') ?></p>
<p><?php the_tags(); ?> </p>
<hr>
<?php the_excerpt(); ?>
<?php comments_template() ?>
<?php endwhile; else: ?>
<p><?php _e('Sorry, there are no posts.'); ?></p>
<?php endif; ?>
</div>
<div class="col-md-4" style="margin-bottom:50px">
<?php get_sidebar(); ?>
</div>
</div>
</div>
</section>
<?php get_footer(); ?>
Thanks in advance for any help!
This is not how the Template Hierarchy works. Yes, your blogpage uses home.php and if it is not found, defaults to index.php. Your assumption about your front page is wrong though.
The front page uses front-page.php, if not found, a custom template or any page.php type template. Check out Creating a static front page
As far the problem with your blogpage, it should be using home.php by default. I think why it is using index.php is due to some caching plugin or browser cache. Clear these caches and check if your problem still exists