我在我的 wordpress 网站上使用高级自定义字段插件。我正在页面上显示来自子页面的转发器字段('photos_presse')的第一张图像('photo')。这是我正在使用的 php 代码。
<?php
$args = array(
'post_type' => 'page',
'post_parent' => $post->ID,
'order' => 'ASC',
'orderby' => 'menu_order',
'post_status' => 'publish',
'number' => 'no limit',
);
$parent = new WP_Query( $args );
if ( $parent->have_posts() ) : ?>
<?php while ( $parent->have_posts() ) : $parent->the_post(); ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<div id="parent-<?php the_ID(); ?>" class="parent-page">
<div class="cartouche_crop">
<?php
$first_img = true;
while($first_img && has_sub_field('photos_presse')): ?>
<img src="<?php the_sub_field('photo'); ?>" class="artists_menu">
<?php $first_img = false; ?>
<?php endwhile; ?>
</div>
<h1><?php the_title(); ?></h1>
</div>
</a>
<?php endwhile; ?>
<?php endif; wp_reset_query(); ?>
这是获取第一张图片的代码部分:
<?php
$first_img = true;
while($first_img && has_sub_field('photos_presse')): ?>
<img src="<?php the_sub_field('photo'); ?>" class="artists_menu">
<?php $first_img = false; ?>
<?php endwhile; ?>
在转发器字段中加载图像时,它会创建缩略图图像,这可以在我的 wordpress 管理员的“媒体设置”菜单中进行设置。(小号中号大号)。
它为每个图像创建 4 个文件,一个小,一个中,一个大和原始 siez。
我想做的不是获取每个转发器字段的第一个原始图像,而是获取转发器字段的第一个中等大小的缩略图。
我找不到如何做到这一点......
有人可以帮我吗?
感谢您的帮助