【发布时间】:2014-12-05 20:13:55
【问题描述】:
我目前正在使用 ACF 5。我已在产品类别上设置了转发器。
我目前正在努力解决如何让它输出信息。我在 acrhive-product 循环中,我正在更新以下包含输出内容的模板:
<?php while ( have_posts() ) : the_post(); ?>
<?php wc_get_template_part( 'content', 'product_cat' ); ?>
<?php endwhile; // end of the loop. ?>
在 content-product_cat.php 中,中继器的每个循环都有以下内容。所有基本信息已经显示,标题,woocommerce 类别图像等。它是我添加到类别本身的中继器,我无法显示。
<?php
$terms = get_field('attributes', 'product_cat_'.$term->term_id);
if($terms): ?>
<ul>
<?php foreach( $terms as $term ): ?>
<li>
<?php the_sub_field('attribute'); ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
任何想法将不胜感激
【问题讨论】:
-
您是否启用了
WP_DEBUG?你可能想要。至少,如果您有未定义的对象/变量,这可能会告诉您。你如何定义$term->term_id?我会从那里开始,因为没有term,你甚至永远不会进入foreach()循环。之后,我对 ACF 的了解就不够了。
标签: php wordpress woocommerce advanced-custom-fields