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. 跳过wp_get_archives()中的最新wordpress帖子
- 9. 功能wordpress中的最新帖子
- 10. WordPress的最新帖子精选图像
- 11. WordPress的打印最新帖子
- 12. 获取最新的帖子,然后在循环中的其他帖子 - Wordpress
- 13. if-else vs if-else-if-else
- 14. WordPress - 在iframe中预览最新的wordpress博客帖子
- 15. 简单的WordPress的if/else
- 16. PHP WordPress主题if/else falling
- 17. if/if else/else
- 18. 从每个类别中获取最新帖子,并在wordpress中添加帖子
- 19. if else else if sql
- 20. Javascript if if else else
- 21. 可以添加最新的自定义帖子类型的最新帖子?
- 22. WordPress的帖子
- 23. Cycle Wordpress帖子
- 24. 风格最新的帖子WordPress的不同
- 25. WordPress的插件最大的帖子
- 26. 最近的帖子凌乱的wordpress
- 27. if else if else in angular js
- 28. if else if else语句(JS)
- 29. 嵌套if-else vs if-else?
- 30. jQuery if if else else filter