You need to add the Loop
to your template to display post content.
Regular loop (the current page).
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article>
<h2><?php the_title(); ?></h2>
</article>
<?php endwhile; ?>
<?php // Navigation ?>
<?php else : ?>
<?php // No Posts Found ?>
<?php endif; ?>
Custom query loop. Notice the wp_rest_postdata()
<?php if ($loop->have_posts()) : ?>
<?php while ($loop->have_posts()) : $loop->the_post(); ?>
<article>
<h2><?php the_title(); ?></h2>
</article>
<?php endwhile; ?>
<!-- reset global post variable. After this point, we are back to the Main Query object -->
<?php wp_reset_postdata(); ?>
<?php else : ?>
<?php // No Posts Found ?>
<?php endif; ?>
You can also use get_template_part()
in the loop, if you like to split your code into smaller pieces and into separate files.