-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

相關問題