How inside new WP_Query to display the ID of the first and last custom post? This is required to loop navigation prev and next
Here is the function code without layout.
$args = array( 'p' => $postID, 'post_type' => 'portfolio-site' ); $recent = new WP_Query($args); while ( $recent->have_posts() ) : $recent->the_post(); if( get_previous_post (true) ) { $first = get_previous_post()->ID; } else { $first = }; $prevPost = $first; if( get_next_post (true) ) { $last = get_next_post()->ID; } else { $last = }; $nextPost = $last; I tried to use get_boundary_post , but could not get it to work. Thank you in advance for any help!