I imported several thousand posts into a base install WordPress website using the great WP All Import Pro plugin.
​
I used the following code snippet to determine what the last post ID was so that I could start the imported posts at the next following number in the sequence.
​
/******************************************
* get latest post
* use in loop if ( is_latest() ) { stuff; }
******************************************/
function latest_post_ID() {
global $post;
$loop = get_posts( ‘numberposts=1’ );
$latest = $loop[0]->ID;
return ( $post->ID == $latest ) ? $post->ID : null;
}
function latest_post_ID2() {
$args = array(
‘post_type’ => ‘any’
);
$the_ID = get_posts($args);
$latest_ID = $the_ID[0]->ID;
echo $latest_ID;
}
function ehw_action_echo_latestPostID( ) {
echo “<H3>HEY! The latest post ID is: ” . latest_post_ID2() . “<H3>”;
}
add_action( ‘wp_footer’, ‘ehw_action_echo_latestPostID’ );
​
The snippet returned **somewhere north of 3000 as the last post URL**. I thought that was odd since I hadn’t created any posts yet. So, logically the post number should have been “1”, one would think.
​
I hadn’t created any posts for that custom post type, nor had I created an plain vanilla posts. But, I imported all 1300+ posts from the old site fine, which was the most important goal at the time.
​
**MY QUESTIONS:**
​
1) Is that normal to have over 3000 posts already created in WordPress on a brand new site with nothing on it?
​
2) How can I restart the numbering scheme for the CUSTOM post type IDS? The old URLS are something like
​
watch.php?ID=1
watch.php?ID=2
…
watch.php?ID=1300
​
But, the new URLs are “pretty permalinks” with the “post name” style for best SEO practice
​
3) If renumbering the post IDs isn’t possible/advisable, what would be a good approach that would allow for mapping the old post ID to the new post ID while still maintaining good SEO? I was considering something like adding the old ID into a custom permalink like
​
https://[oldsite.com]/[old-id]/[post-name-slug]
​
​
Thanks in advance
[ad_2]
1. Depends, it’s not counting posts, it’s counting the posts table which encompasses practically everything on the site that isn’t users or settings. So every page, every post, every custom post type, every image, etc. etc.
2. That’s a database thing, and i strongly advice you don’t do this.
3. By default setting your site up to using pretty permalinks should rewrite the older way of querying pages to the new prettier linked page. So ?id=1400 goes to /new-page-for-id1400.
The problem is that not only posts increment the post_id. Even if you did manage to renumber your posts starting from 1, you would likely still end up with jumps/holes in the post numbers going forward.