How to get latest post ID from WordPress page
-
Hi this should be simple. How can I get the latest WordPress Blog Post ID when I am on WordPress page? I have code that works on static php pages but when I put the code on my home page it doesn’t work. It only shows info on the current page.
Here is my code that works on non wordpress pages.
<?php include('wp-blog-header.php'); ?> <?php $postslist = get_posts('numberposts=1&order=DESC&orderby=post_title'); foreach ($postslist as $post) : setup_postdata($post); ?> <?php $thePostID = $post->ID; // gets the post id ?> <?php endforeach; ?>
This should be irrelevent but in case not I am using “Allow PHP in posts and pages” to run my php script from within my WordPress page. I am also on WordPress 3.0.1.
Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to get latest post ID from WordPress page’ is closed to new replies.