我从类别“66”中获得 10 个帖子,但我想显示第一个带有大缩略图的帖子,其余的帖子带有小缩略图,也许中间的一些帖子带有大缩略图。我有 CSS 中的代码,但我不知道如何指定何时调用来自同一类别的 10 个帖子。我不想从 mysql 进行两次调用,因为我想要从最新到最旧的订单...
谢谢。
<?php
global $post;
$args = array( 'numberposts' => 10, 'order' => 'ASC', 'category' => 66 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<div id="lajme-bllok-item-vogel">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('lajmi-thumb'); ?></a>
<div id="lajme-bllok-item-title-vogel"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<div id="top-news-title-linku"><?php for( $i=1; $i<=4; $i++){ $prop_det_url = get_field('link'.$i); if( $prop_det_url != '' ){ ?>
<a href="<?php echo $prop_det_url; ?>" target="_blank">/ <?php the_field('link_titull'.$i); ?></a> <?php } } ?></div>
</div>
<?php endforeach; ?>
最佳答案
一个解决方案:
将类别作为类名放入 HTML 标记中,例如<div class="category66">
然后使用 nth-child
为每个类生成一个 css 选择器?
例如
.category66 {
width: 100px;
height: 100px;
}
.category66:nth-child(1) {
width: 200px;
height: 200px;
}
关于php - 帖子的图像大小自定义CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22984746/