您可以在循环中使用wp_get_attachment_image
.
类似(未测试):
//loop starts
//values for get_posts ( or wp query if you prefer)
$args = array(
\'post_type\' => \'attachment\', //gets the attachments aka your images
\'numberposts\' => -1,
\'post_parent\' => $post->ID
);
// some attributes you want added to each image
$default_attr = array(
\'class\' => "background-attachment", //for your javascript
\'alt\' => \'something\',
\'title\' => \'\'something
);
//loops through the attachments,
//uses the \'full\' parameter assuming you want the default large image
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
echo wp_get_attachment_image($attachment->ID, \'full\', false, $default_attr);
}
}
//loop ends
//your javascript for full page background via wp_enqueue_script