Php 用于帖子的图像大小自定义css
iAM从“66”类中获得10篇文章,但我想用大拇指缩略图显示第一篇文章,其余文章用小缩略图显示,Maybe在中间用大拇指缩略图。我有CSS中的代码,但我不知道如何指定何时调用同一类别的10篇文章。我不想从mysql打两个电话,因为我想要从最新到最旧的邮购 多谢各位Php 用于帖子的图像大小自定义css,php,html,mysql,css,wordpress,Php,Html,Mysql,Css,Wordpress,iAM从“66”类中获得10篇文章,但我想用大拇指缩略图显示第一篇文章,其余文章用小缩略图显示,Maybe在中间用大拇指缩略图。我有CSS中的代码,但我不知道如何指定何时调用同一类别的10篇文章。我不想从mysql打两个电话,因为我想要从最新到最旧的邮购 多谢各位 <?php global $post; $args = array( 'numberposts' => 10, 'order' => 'ASC', 'category'
<?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标记中,例如
然后使用第n个子类为每个类生成css选择器
e、 g
您可以在代码周围添加一个
if语句
,并说如果它是第一个结果集,则设置大图像,否则设置小图像。未经测试,但应该有效
<?php
global $post;
$args = array( 'numberposts' => 10, 'order' => 'ASC', 'category' => 66 );
$myposts = get_posts( $args );
$count = 1;
foreach( $myposts as $post ) : setup_postdata($post);
if($count=1)
{
?>
<div id="lajme-bllok-item-vogel">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('lajmi-thumb'); ?></a> //Set the big thumbnail there
<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
$count = 2;
}
else
{
?>
<div id="lajme-bllok-item-vogel">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('lajmi-thumb'); ?></a> //Set the small thumbnail there
<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; ?>
//将大缩略图设置在那里
//将小缩略图设置在那里
您可以定义不同的类/图像大小,并在循环中运行计数器,根据计数器调用这些类/图像大小。
<?php
global $post;
$args = array( 'numberposts' => 10, 'order' => 'ASC', 'category' => 66 );
$myposts = get_posts( $args );
$count = 1;
foreach( $myposts as $post ) : setup_postdata($post);
if($count=1)
{
?>
<div id="lajme-bllok-item-vogel">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('lajmi-thumb'); ?></a> //Set the big thumbnail there
<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
$count = 2;
}
else
{
?>
<div id="lajme-bllok-item-vogel">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('lajmi-thumb'); ?></a> //Set the small thumbnail there
<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; ?>