我想让我最近的文章显示一个大缩略图,其中包含更大的缩略图和更多的内容,而循环中的其他帖子显示一个小缩略图,只有标题没有内容。
有没有一种方法我可以用一个while(have_posts())
环
我想让我最近的文章显示一个大缩略图,其中包含更大的缩略图和更多的内容,而循环中的其他帖子显示一个小缩略图,只有标题没有内容。
有没有一种方法我可以用一个while(have_posts())
环
检查内置计数器$wp_query->current_post
在循环内:
<?php
while( have_posts() ) :
the_post();
if( 0 == $wp_query->current_post ):
// this is the first post in the loop, output larger size, full content, etc.
else:
// output regular size, the_excerpt, etc.
endif;
endwhile;
?>
我不是wordpress专家,但你能使用两个循环吗?一个显示最新的帖子,另一个显示之后的帖子,以获得不同的CSS?
因此,请循环查看最近的。。。
<?php $my_query = new WP_Query(\'showposts=1\');
while ($my_query->have_posts()) : $my_query->the_post(); ...
和第二个循环(将立柱偏移1) <?php $offset = new WP_Query(\'offset=1&showposts=5\');
while ($offset ->have_posts()) : $offset->the_post()...
您可以更改showposts=5,以在剩余循环中显示所需的帖子数。我有一个网站,它有一个静态首页和一个博客页面,其中显示所有博客。我正在使用自己的主题,并创建了一些自定义元框,这些元框根据$post->ID. 我得到的有趣行为是$post->ID 给我第一个博客的ID,而不是博客页面本身的ID。我在循环外使用$post,并已将其声明为全局,但没有任何效果。我还尝试使用$wp_query->post->ID 但这给了我最后一篇帖子的ID。相关代码是我使用$post的地方,下面是这段代码位于页脚。php:<?php require_once(\