WordPress的第一个帖子只在第一页不同于其他
问题描述:
得到下一个代码,以获得第一个页面上的第一个WordPress的帖子是不同的。但它不起作用。看着其他问题和答案,但似乎没有一个好的答案。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”,但不能找出原因。 有谁知道如何正确完成这件事?
在此先感谢!
Joeri
答
看起来你不必为内if
的endif
做。也许应该是:
<?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 endif; ?>
我的..完全错过了..谢谢你的快速回答! – Codigit 2015-01-31 20:07:07
现在我已经提出了整个代码和东西;)关于如何在第一页显示不同数量的帖子而不是在其他页面上的任何想法。这是因为它是一个2列的界面,现在第一页上的较小的帖子是不均匀的..会让我的一天!干杯 – Codigit 2015-01-31 20:24:53
@ user3241326,如果答案是正确的,upvoting它并接受它会让人们知道! – ASGM 2015-01-31 21:57:11