【发布时间】:2015-04-19 18:30:57
【问题描述】:
我正在创建一个 wordpress 网站,将帖子显示为网格中的图像。我已经在网格之前显示了帖子的类别和标签,我希望根据所选标签或类别实现对缩略图的过滤。但是,它目前似乎不起作用。即使选择了标签或类别,也会显示所有帖子。
<div id="grid">
<div class="container">
<div class="row text-center">
<?php
$thumbnails = get_posts( 'numberposts=500' );
foreach ( $thumbnails as $thumbnail ) {
if ( has_post_thumbnail( $thumbnail->ID ) ) {
echo '<div class="col-md-4 col-lg-4"><a href="' . get_permalink( $thumbnail->ID ) . '" title="' . esc_attr( $thumbnail->post_title ) . '">';
echo get_the_post_thumbnail( $thumbnail->ID, 'large' );
echo '</a></div>';
}
}
?>
</div>
</div>
</div>
我怀疑它与“numberposts”有关,但即使我更改它,帖子仍然没有被过滤。
你知道是什么原因造成的吗?
【问题讨论】:
-
提供的代码中没有进行过滤。
标签: php wordpress image twitter-bootstrap thumbnails