高级自定义字段不返回结果 [英] advanced custom field not return back result
问题描述
我使用的是高级自定义字段,并且我创建了自定义作者字段(可以是Publisher或Brand等),现在此作者的姓名不在产品(书)页面上打印。在自定义字段中,其作者姓名的名字是姓名
i am using advanced custom filed and i made custom author field (it could be Publisher Or Brand etc) now this author's name is not printing on product (Book) page . in custom field its for author's name slug is 'names'
add_action( 'woocommerce_after_single_product_summary', "ACF_product_content", 10 );
function ACF_product_content(){
echo '<h2> ACF Content </h2>';
if (function_exists('the_field')){
echo '<p>Woohoo, the_field function exists! </p>';
//the_field('authors');
echo '<pre>';
print_r(get_the_ID());
echo '</pre>';
echo '<pre>';
print_r(get_field('authors'));
echo '</pre>';
die;
}
}
为此,我得到了结果
查看此报告屏幕截图
。现在的问题是在此数组中显示作者名称为[’post_title’]。
我尝试了很多解决方案,但不工作,没有显示结果。
for this i got the result Check this report screenshot . now problem is to show the Authors name which is ['post_title'] in this array. i tried so many solutions but not working its not showing the result. i used to show this result by this code
echo the_field('names';;
名称是作者自定义字段中的字段名称。
'names' is the field name in 'Authors' custom field.
推荐答案
为ACF尝试使用此代码
try this code for ACF
<?php
echo get_field('your custom filed slug name',get_the_ID());
?>
获取帖子标题
<?php echo get_the_title(); ?>
显示以下功能的作者姓名
for display author name for below function
<?php echo get_the_author(); ?>
这篇关于高级自定义字段不返回结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!