Php 循环时,WordPress查找当前id并获取下一个id
使用while循环Php 循环时,WordPress查找当前id并获取下一个id,php,wordpress,Php,Wordpress,使用while循环 <?php $current_id = get_the_ID(); echo $current_id; $args=array( 'portfolio-tag' => 'corporate', 'showposts'=>0, 'orderby'=>'post_date', 'order'=>'ASC', 'caller_get_posts'=>1 ); $my_query = new WP_Query($args); i
<?php
$current_id = get_the_ID();
echo $current_id;
$args=array(
'portfolio-tag' => 'corporate',
'showposts'=>0,
'orderby'=>'post_date',
'order'=>'ASC',
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();
echo get_the_ID();
endwhile;
}
wp_reset_query();
?>
这些是公文包项目id。如果我是当前的详细信息页面id是368,那么我试图实现的就是使用这个
get_the_ID();
有人能告诉我如何在while循环中找到当前的id吗?在这种情况下,368在第二个号码上。所以我需要420 id,因为420在368之后出现。这就是它的用途:
这是不工作在我的情况下,我正在更新我的整个代码上面你可以检查。我得到的职位有公司标签。然后运行一个while循环,使所有内容都在post上。我必须找到下一个帖子的id,然后是当前的帖子id。但这应该在这个while循环中。你能再看看我的问题吗?现在它更清楚了。我必须找到下一个id,然后是当前id。从while循环。while显示所有带有“corporate”标签的帖子id,我只需要下一个。网址
get_the_ID();
if( $my_query->have_posts() ) : while ($my_query->have_posts()) : $my_query->the_post();
the_ID(); // display the current post ID
$next_post = get_next_post();
echo !empty( $next_post ) ? 'Next Post ID: ' . $next_post->ID : 'No next post';
endwhile; endif;