0
votes

I have my main blog page that I have output all the post thumbnails and titles on for a navigation for my portfolio.

Here is the code that outputs the thumbnail gallery:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
        <a href="<?php echo get_permalink(); ?>">
            <div class="mainpost">
                <div class="mainpostimage" style="background-image:url('<?php echo wp_get_attachment_url(get_post_thumbnail_id()) ?>')"></div>
                <h1><?php the_title(); ?></h1></div>
        </a>

        <?php endwhile; endif; ?>



</div>

And This is the live page.

I have the single.php file set up to output the post content but I want it to display the entire list of thumbnails underneath so the viewer can view the post and see basically the same thing as the blog index.php page. I copied the same code and placed it inside the wordpress while loop, but it only outputs the thumbnail for the current page.

Here is the code for my single.php page.

    <div id="primary" class="content-area">
        <main id="main" class="site-maina" role="main">

        <?php while ( have_posts() ) : the_post(); ?>

            <?php get_template_part( 'template-parts/content', 'single' ); ?>


<div class="morestuffhere">
                <a href="<?php echo get_permalink(); ?>">
                <div class="mainpost">
                    <div class="mainpostimage" style="background-image:url('<?php echo wp_get_attachment_url(get_post_thumbnail_id()) ?>')"></div>
                    <h1><?php the_title(); ?></h1></div>
            </a>

</div>
         <?php the_post_navigation(); ?> 

        <?php endwhile; // End of the loop. ?>

        </main>
    </div>

This is a link to sample post page with only a thumbnail for the current post

1

1 Answers

0
votes

Just go to the setting and make your blog post page the front page or home page and your all post will be showing on the home page