在以前安装的WordPress中,可以在attachment.php
使用下面最初提供的代码here. 然而,我发现这个代码不再有效,因为图像编号不准确。
是否有新代码可用?
<?php
global $post;
$ancestors = get_post_ancestors($post->ID);
$photos = get_children(array(
\'post_mime_type\' => \'image\',
\'post_parent\' => array_shift($ancestors),
));
$index = 0;
foreach($photos as $photo){
$index++;
if($photo->ID === $post->ID) break;
}
printf(\'%d out of %d\', $index, count($photos));
?>