I'm trying to add the post id's to the next and previous posts. Currently using the following code gives me the undesired effect of post id of the page displayed.
<div id="post-<?php the_ID(); ?>" class="project-tile nextproject">
<a href="#"><?php next_post('%','', TRUE, '1'); ?></a></h2>
</div><!-- /project-tile -->
<div class="project-tile previousproject">
<a href="#"><?php previous_post('%','', TRUE, '1'); ?></a>
</div><!-- /project-tile -->
// Works inside and outside of the Loop
function function_name() {
global $post;
$thePostID = $post->ID;
}
//or
echo $post->ID
Outside of the loop, use the post object WP post ID outside of loop or you can use just the one call if you don't want to set up a function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.