我使用这个简单的查询实现了它
<?php
$chunks=array_chunk(
get_posts([
\'fields\'=>\'ids\',
\'posts_per_page\'=>-1,
\'post_type\'=>[$post->post_type],
\'orderby\'=>\'ID\',
\'order\'=>\'ASC\'
]),
wp_sitemaps_get_max_urls(\'post\')
);
foreach($chunks as $key => $chunk) {
if(!in_array($post->ID,$chunk)) continue;
var_dump(get_sitemap_url(\'posts\',$post->post_type,$key + 1));
break;
}