-1

我已经使用Advance Custom Field(ACF)wordpress插件添加了Woocommerce - >产品 - >类别表单中的自定义字段。如何使用ACF插件显示分类术语自定义字段值

现在我无法在类别页面上打印该字段值。

请参阅此屏幕快照了解字段slug名称和其他详细信息 - >http://nimb.ws/BsSiJO并帮助我在类别页面上显示字段值。

谢谢, Ketan。

+0

你有没有期限能否成功添加类别?我的意思是在后端? –

+0

是的,我已经在后端方面成功添加类别。现在我想在woocommerce类别名称下面显示自定义提交的文本。 – Ketan

+0

在前端的权利? –

回答

0

显示的字段

<p><?php the_field('field_name', $term); ?></p> 

检索领域

<?php 

$variable = get_field('field_name', 'product-cat_23'); 

// do something with $variable 

?> 

查找与当前后

<?php 

// load all 'category' terms for the post 
$terms = get_the_terms(get_the_ID(), 'category'); 


// we will use the first term to load ACF data from 
if(!empty($terms)) { 

    $term = array_pop($terms); 

    $custom_field = get_field('category_image', $term); 

    // do something with $custom_field 
} 

?> 
+0

感谢您的评论。但上面的代码,我也看到ACF文件,但不能帮助我。 所以请检阅这个我的领域http://nimb.ws/BsSiJO和你能为我做出完美的代码。 谢谢。 – Ketan

相关问题