I have been working on this for hours and don't know what I'm overlooking or not understanding. I'm trying to use get_template_part
to call another php document. When I run the code below there is nothing in the div.content
. I don't understand why my partial-banner.php is being called.
front-page.php
<?php get_header(); ?>
<div class="content">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'template-parts/partial', 'banner' ); ?>
<?php endwhile; // end of the loop. ?>
</div>
<?php get_footer(); ?>
partial-banner.php
<section class="banner">
<h1>Does this work</h1>
</section>
and here's an image of my file structure.
have_posts
? Maybe try confirming this with<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
, and also making sure to end your while with<?php endwhile; else : ?> <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p> <?php endif; ?>
. Also, you will need to ensure you setWP_USE_THEMES
to false if you are using your own design:<?php define( 'WP_USE_THEMES', false ); get_header(); ?>
.<p>
inside of the loop it is displayed on the front-page. Thanks for the suggestions though.