My front page displays the latest posts using index.php.
My page.php contains the wp_header up top, the wp_footer below, and this in between:
while (have_posts()) : the_post(); get_template_part( 'content', 'page' ); endwhile; My content-page.php is supposed to print out the_content() and the the_title() of the page, but it returns the content and title of all the posts. What am I missing?
The page is set to 'Default Template'.
I've added my page.php and content-page.php below:
page.php:
<?php /* Page */ ?> <?php get_header(); ?> <div class="container-fluid"> <div class="container"> <?php while (have_posts()) : the_post(); get_template_part( 'content', 'page' ); endwhile; ?> </div> </div> <?php get_footer(); ?> content-page.php
<?php /* The template used for displaying page content in page.php */ ?> <?php echo '<div class="row">'; echo '<div class="col-sm-12">'; echo the_title( '<h2>', '</h2>'); echo '<p>' . the_content() . '</p>'; echo '</div>'; echo '</div>'; ?> index.php
<?php /* Main file */ ?> <?php get_header(); ?> <div class="container-fluid"> <div class="container"> <?php if(have_posts()) : while (have_posts()) : the_post(); echo '<div class="row'; if($count > 2){ echo ' hideme'; } echo '">'; echo '<div id="section-'. $count++ .'" class="col-sm-12" style="text-align:center;">'; echo '<p><a href="' . get_permalink( get_the_ID() ) . '">'; echo the_post_thumbnail(); echo '<br>' . get_the_title() . ' // ' . get_the_category_list(', ') . '</a></p>'; echo '</div>'; echo '</div>'; endwhile; endif; ?> </div> </div> <?php get_footer(); ?>
page.phpandcontent-page.phpand notPage.phpandContent-page.php? Capital letters and lower case letters are not the same. Also have you usedquery_postsanywhere in your code?