问题描述
我正在尝试使用ACF创建自定义块。我在这里关注了他们的详细信息:https://www.advancedcustomfields.com/resources/blocks/
它显示2个帖子。.但没有数据。
附上了我的代码,并查看了ACF网站,但我无法找出我做错了什么。请帮忙。
<?PHP
/**
* Client Slider Template.
*
* @param array $block The block settings and attributes.
* @param string $content The block inner HTML (empty).
* @param bool $is_preview True during AJAX preview.
* @param (int|string) $post_id The post ID this block is saved to.
*/
?>
<?PHP
$featured_posts = get_field('clients');
if( $featured_posts ): ?>
<div class="owl-carousel owl-theme work-snippets">
<?PHP foreach( $featured_posts as $post ):
setup_postdata($post); ?>
<div>
<?PHP
$image = get_field('client_logo');
if( !empty( $image ) ): ?>
<img src="<?PHP echo esc_url($image['url']); ?>" alt="<?PHP echo esc_attr($image['alt']); ?>" />
<?PHP endif; ?>
<p><strong><?PHP the_field( 'project_title' ); ?></strong></p>
<p><?PHP the_field( 'project_overview' ); ?></p>
</div>
<!-- Close Work Snippet -->
<?PHP endforeach; ?>
</div>
<!-- Work Snippets -->
<?PHP wp_reset_postdata(); ?>
<?PHP endif; ?>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)