wordpress:如何在single.php中的singlepost下添加post索引



我有我的主博客页面,我已经在上面输出了所有的文章缩略图和标题,用于导航我的作品集。

以下是输出缩略图库的代码:

    <?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>

这是实时页面。

我设置了single.php文件来输出文章内容,但我希望它在下面显示整个缩略图列表,这样观众就可以查看文章,并看到与博客index.php页面基本相同的内容。我复制了相同的代码,并将其放置在wordpresswhile循环中,但它只输出当前页面的缩略图。

这是我的single.php页面的代码。

    <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>

这是一个链接到示例文章页面,只有当前文章的缩略图

只需进入设置,将您的博客文章页面设置为首页或主页,您的所有文章都将显示在主页

最新更新