Sorry for this simple question, I am very new to Wordpress.

I have a simple index.php that show a view of posts, just the images.

When I click on any post, it should send me to the full view of the post, which is defined in the page.php This is the code of my page.php is the same from this answer

<?php get_header() ?>

    // Start the loop.
    while ( have_posts() ) : the_post();

        // Include the page content.

    // End the loop.

<?php get_footer() ?>

It shows the index.php, but in the list of post, it shows just one element, the element that I clicked.

this is my index.php

<?php get_header(); ?>
  <body id="page-top">
    <!-- Navigation -->
      <?php get_template_part( 'navigation'); ?>
    <!-- Header -->
      <?php get_template_part( 'banner'); ?>
    <!-- Portfolio Grid Section -->
      <?php get_template_part( 'portfolio'); ?>
    <!-- About Section -->
    <?php get_template_part( 'about'); ?>
    <!-- Contact Section -->
    <?php get_template_part( 'contact'); ?>
<?php get_footer(); ?>

And this is the portafolio template, that show the list of all the posts:

  get_template_part('recent', 'posts');
  if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  <div class="col-md-6 col-lg-4">
    <!-- print the post link -->
    <a class="portfolio-item d-block mx-auto" href="<?php the_permalink(); ?>">
      <div class="portfolio-item-caption d-flex position-absolute h-100 w-100">
        <div class="portfolio-item-caption-content my-auto w-100 text-center text-white">
          <i class="fa fa-search-plus fa-3x"></i>
      <!-- print the post image -->
    <?php the_post_thumbnail('', array('class' => 'img-fluid')); ?>
  <?php endwhile; endif; ?>

This is how looks the index.php, enter image description here

and the page.php enter image description here

  • 1
    if you are viewing single posts of the post type, then single.php is the more specific template. page.php is for the page post type. – Milo Dec 29 '17 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.