phpwordpress

get_template_part not working on wordpress


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.


Solution

  • I was not calling the file correctly according to the file structure. Fix is below.

    get_template_part( 'library/template-parts/partial', 'banner' );