[英]Woocommerce category ACF field not showing
First of all I'm saying this is not a duplicated question i tried other answers but not worked. 首先,我说这不是重复的问题,我尝试了其他答案,但是没有用。
I added ACF field to woocommerce category and i need to shows that on woocommerce category archive pages. 我将ACF字段添加到woocommerce类别,我需要在woocommerce类别存档页面上显示该字段。
Below shows how i add ACF 下面显示了我如何添加ACF
http://www.awesomescreenshot.com/image/1859170/1fb3dc839dff36c92d4ee52f5167ca78 http://www.awesomescreenshot.com/image/1859170/1fb3dc839dff36c92d4ee52f5167ca78
http://www.awesomescreenshot.com/image/1859175/1d1e43f70ae925ac5501f9e360f4a463 http://www.awesomescreenshot.com/image/1859175/1d1e43f70ae925ac5501f9e360f4a463
It shows on product category admin area 它显示在产品类别管理区域
http://www.awesomescreenshot.com/image/1859197/c5df7d20319c73d94896058daa6f3f2a http://www.awesomescreenshot.com/image/1859197/c5df7d20319c73d94896058daa6f3f2a
But when i tried to shows on category page on fronted it not showing, 但是,当我尝试在前面的类别页面上显示时,它没有显示,
<?php
$queriedObject=get_queried_object();
echo get_field('categoryslider','product_cat_'.$queriedObject->term_id);
?>
Above code i got from stack overflow, i also tried other few solutions but it didn't worked, I'm using latest versions of all plugins. 上面的代码是我从堆栈溢出中获得的,我也尝试了其他一些解决方案,但没有成功,我使用的是所有插件的最新版本。
can anyone help me please. 谁能帮我。 Thank You
谢谢
As the document said: https://www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ , you have three ways to get the field value. 如文档所述: https : //www.advancedcustomfields.com/resources/get-values-from-a-taxonomy-term/ ,您有三种获取字段值的方法。
Here is my test: 这是我的测试:
//It works
$queriedObject = get_queried_object();
echo get_field('categoryslider','product_cat_'.$queriedObject->term_id);
//not working, Added in version 5.5.0
$queriedObject = get_queried_object();
echo get_field('categoryslider','term_'.$queriedObject->term_id);
//It works!
$queriedObject = get_queried_object();
echo get_field('categoryslider', $queriedObject);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.