0
我有一個博客(離線製作),我做了一個wordpress循環,它檢查是否第一次發佈它使用不同的風格和其他帖子的其餘使用不同的。WordPress的只是首先發布不同的設計
問題是:它工作正常,但是當我轉到下一頁(2)時,它再次顯示,我只想申請第一條最新帖子。不適用於每頁上的第一篇文章。
代碼:
<?php
while (have_posts()) : the_post();?>
<?php $count++; ?>
<?php if ($count == 1 && is_home()) :
//First post different style goes here
<?php else : ?>
//Rest Other post different style goes here
<?php endif; ?>
<?php
endwhile;
?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e('Nothing Found', 'twentyeleven'); ?></h1>
</header><!-- .entry-header -->
<div class="page_content">
<p><?php _e('Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven'); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>
感謝名單伴侶,它的工作@Stanimir Stoyanov,另外我怎樣才能平衡每個頁面的帖子數量,截至目前設置爲從wordpress閱讀部分到13。 當我轉到第二頁時,帖子的數量並不準確,它在結尾丟失。 – Vinayak
據我瞭解,你想每個博客頁面的職位數量相等,對吧? 您應該創建自定義查詢,跳過Reading設置中設置的posts_per_page。 –
是的,這是正確的,在主頁上第一篇文章是滑塊和總帖子是13在第二頁其簡單的基本3個網格的職位。對於第二頁,我們跳過滑塊,以便在第二頁上有額外的一個帖子。例如:建立這種風格的帖子https://templated.co/檢查第一頁和第二頁 – Vinayak