尚未对此进行测试,但关键是使用get_posts()
使用适当的参数来检索附件的ID,例如。
$args = array(
\'post_type\' => \'attachment\',
\'numberposts\' => -1,
\'post_status\' => null,
\'post_parent\' => $post->ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
echo \'<li>\';
the_attachment_link( $attachment->ID, true );
echo \'<p>\';
echo apply_filters( \'the_title\', $attachment->post_title );
echo \'</p></li>\';
}
}
请参见
https://codex.wordpress.org/Function_Reference/get_attachment_link 和
https://codex.wordpress.org/Function_Reference/the_attachment_link.
就图像尺寸而言,您可能需要CSS,除非您只想按原样显示图像。