【发布时间】:2023-07-10 10:05:01
【问题描述】:
获得了下一个代码,以使第一页上的第一个 Wordpress 帖子有所不同。但它不起作用。查看了其他问题和答案,但似乎没有一个很好的答案。
这是我所拥有的,但对我不起作用:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array('posts_per_page' => 5, 'paged' => $paged );
query_posts($args); ?>
<?php if (have_posts()) : ?>
<?php $postcount = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $postcount++; ?>
<?php if ($postcount == 1 && $paged == 1) : // if this is the first post & first page ?>
<div class="large-10">
<?php the_post_thumbnail('large'); ?>
</div>
<?php else : //if this is NOT the first post ?>
<div class="large-6 columns">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="portfolio">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('large'); ?>
<span><h6><?php the_title(); ?></h6></span>
</a>
</div>
</article>
</div>
<?php endwhile; ?>
<?php endif; ?>
我收到此语法错误“意外的 T_ENDWHILE”,但不知道原因。 有谁知道如何正确完成这项工作?
提前致谢!
乔里
【问题讨论】: