如何在单个 post 的末尾显示类别中 post 的缩略图?

How to show thumbnails of posts in a category at the end of a single post?

我昨天 post 编辑了这个,但是当我注册时我再也看不到这个问题了,如果它现在在这里出现两次,我深表歉意!

我试图在单个页面的末尾显示缩略图网格。我的网格在我的“工作”页面上工作正常,这是一个类别页面。它们使用下面的代码显示为缩略图网格。你可以在网站上看到 Here.

<?php
get_header(); ?>

<div class="grid work thumb-wrap clearfix">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
                    

        <a class="thumb" href="<?php the_permalink(); ?>">
            <img src="http://www.nathanspence.com/wp-content/uploads/<?php echo get_post_meta($post->ID, 'thumb', true); ?>"/>
            <div class="post-excerpt">
                <h2><?php echo get_the_title($ID); ?></h2>
                <div class="sub-title"><?php echo get_post_meta($post->ID, 'project-name', true); ?></div>
            </div>      
        </a>

                    
        <?php endwhile; ?>
        <?php endif; ?>

</div><!--end of "thumb-wrap"-->

<div class="push"></div>
    
</div><!--end of "page-wrap"--> 

<?php get_footer(); ?>

我想在每首单曲的末尾复制这个 post。 Here.

<?php get_header(); ?>

<div class="page-content">

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

<article class="work post-content ready-to-column clearfix">
                
    <header class="post-header column-left">
        <h1><?php echo get_the_title($ID); ?></h1>
        <h2><?php echo get_post_meta($post->ID, 'project-name', true); ?></h2>
        <div class="project-info"><?php echo get_post_meta($post->ID, 'project-info', true); ?></div>                   
    </header>
    
    <div class="column-right">
    <?php the_content(); ?>
    
        

    
    
    
    </div><!---end of "right-column flex-column"--->

            
</article>
    
<?php endwhile; else: ?>    
<p>Sorry, this post does not exist</p>
<?php endif; ?>
    
    <div class="grid work thumb-wrap clearfix">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();?>
                    

        <a class="thumb" href="<?php the_permalink(); ?>">
            <img src="http://www.nathanspence.com/wp-content/uploads/<?php echo get_post_meta($post->ID, 'thumb', true); ?>"/>
            <div class="post-excerpt">
                <h2><?php echo get_the_title($ID); ?></h2>
                <div class="sub-title"><?php echo get_post_meta($post->ID, 'project-name', true); ?></div>
            </div>      
        </a>

                    
        <?php endwhile; ?>
        <?php endif; ?>

</div><!--end of "thumb-wrap"-->

<div class="push"></div>
    
</div><!--end of "page-wrap"--> 

<?php get_footer(); ?>

我想在单个 post 结束时显示此网格。我试过将相同的循环粘贴进去,但如您所见,简单地粘贴它只会显示当前的 posts 缩略图。知道我该怎么做吗?我是一名设计师,刚刚开始学习如何维护自己的网站,所以我对循环等方面的知识有点迷茫。谢谢!

编辑:所以为了更清楚。我如何获得下面的代码以在单个 post?

的末尾输出该类别中的所有 posts
<a class="thumb" href="<?php the_permalink(); ?>">
            <img src="http://www.nathanspence.com/wp-content/uploads/<?php echo get_post_meta($post->ID, 'thumb', true); ?>"/>
            <div class="post-excerpt">
                <h2><?php echo get_the_title($ID); ?></h2>
                <div class="sub-title"><?php echo get_post_meta($post->ID, 'project-name', true); ?></div>
            </div>      
        </a>

试着把这个添加到你想要的地方 post

<?php 
$wpb_all_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=>-1)); ?>
 
<?php if ( $wpb_all_query->have_posts() ) : ?>
 
<ul>
 
    <!-- the loop -->
    <?php while ( $wpb_all_query->have_posts() ) : $wpb_all_query->the_post(); ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    <!-- end of the loop -->
 
</ul>
 
    <?php wp_reset_postdata(); ?>
 
<?php else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>