从某些 post 类型获取所有图像,但具有完整尺寸
Get all image from certain post type but with full size
我不知道为什么,但是这段代码将图像大小设置为缩略图 150x150
the code is in this question: Get all image from certain post type
enter$query = new WP_Query( array( 'post_type' => 'custom-post', posts_per_page' => -1 ) );if( $query->have_posts() ){
while($query->have_posts()){
$query->the_post();
$image_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => 'image', 'posts_per_page' => -1, 'post_parent' => get_the_ID() ) );
while( $image_query->have_posts() ) {
$image_query->the_post();
echo wp_get_attachment_image( get_the_ID() );
}
}}
是否可以更新此代码以更改图像尺寸中号或大号?
你能用这个测试吗?
wp_get_attachment_image( get_the_ID(), $size = 'large');
如果您想了解更多信息,请阅读此处:
https://developer.wordpress.org/reference/functions/wp_get_attachment_image/
我不知道为什么,但是这段代码将图像大小设置为缩略图 150x150
the code is in this question: Get all image from certain post type
enter$query = new WP_Query( array( 'post_type' => 'custom-post', posts_per_page' => -1 ) );if( $query->have_posts() ){
while($query->have_posts()){
$query->the_post();
$image_query = new WP_Query( array( 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => 'image', 'posts_per_page' => -1, 'post_parent' => get_the_ID() ) );
while( $image_query->have_posts() ) {
$image_query->the_post();
echo wp_get_attachment_image( get_the_ID() );
}
}}
是否可以更新此代码以更改图像尺寸中号或大号?
你能用这个测试吗?
wp_get_attachment_image( get_the_ID(), $size = 'large');
如果您想了解更多信息,请阅读此处:
https://developer.wordpress.org/reference/functions/wp_get_attachment_image/