0
A
回答
0
是的,這是可能的。主查詢之前運行自定義查詢,以獲得最新的崗位,並比較它們的ID:
// get 1 most recent post
$query_args = array(
'showposts' => 1 // here you can add limit by categry etc
);
$query = new WP_Query($query_args);
$query->the_post();
$recent_post_ID = $post->ID; // this is your most recent post ID
// this is your main loop
if (have_posts()) while (have_posts()) : the_post();
if ($post->ID == $recent_post_ID) { // check if IDs are equeal or not
// You are viewing most recent entry
} else {
// You are viewing older entry
}
0
您可以用WordPress的原生功能也試試這個檢索最新的帖子
<?php
$args = array('numberposts' => '1');
$recent_posts = wp_get_recent_posts($args);
$latest_post_id=$recent_posts[0]['ID'];
if (have_posts()) : while (have_posts()) : the_post(); ?>
if ($post->ID == $latest_post_id)
{
// code for newest post
}
else
{
// code for other than the newest post
}
endwhile;
endif;
?>
相關問題
- 1. WordPress最新帖子輪播
- 2. 最新帖子bootstrap網格wordpress
- 3. Randomise X最新的WordPress的帖子
- 4. WordPress的帖子最後的帖子
- 5. 拉最新論壇WordPress內的帖子
- 6. Wordpress - 強制最新帖子第一
- 7. WordPress的最新帖子精選圖像
- 8. WordPress的最新帖子菜單項
- 9. PHP的WordPress的 - 最新的3帖子
- 10. WordPress的打印最新帖子
- 11. 訂購WordPress的帖子最新評論
- 12. 跳過wp_get_archives()中的最新wordpress帖子
- 13. 功能wordpress中的最新帖子
- 14. 博客頁面=最新帖子在WordPress
- 15. WordPress的最新消息佈局帖子
- 16. 如何顯示最新帖子Wordpress
- 17. WordPress的新帖子
- 18. 獲取最新的帖子,然後在循環中的其他帖子 - Wordpress
- 19. if-else vs if-else-if-else
- 20. WordPress - 在iframe中預覽最新的wordpress博客帖子
- 21. PHP的if/else get_field()與WordPress
- 22. PHP WordPress主題if/else falling
- 23. 簡單的WordPress的if/else
- 24. if/else聲明爲wordpress metabox
- 25. if/if else/else
- 26. 從每個類別中獲取最新帖子,並在wordpress中添加帖子
- 27. 可以添加最新的自定義帖子類型的最新帖子?
- 28. if else else if sql
- 29. Javascript if if else else
- 30. wordpress如何顯示最近更新的頁面和帖子