如何从模板页面的数据库获取字段值高级自定义字段 - wordpress
问题描述:
我已经安装了一个高级自定义字段插件来上传音频和图像文件。每个帖子包含5场如何从模板页面的数据库获取字段值高级自定义字段 - wordpress
我可以能够发表这篇文章,但我不知道如何在WordPress模板页面
答
你可以做这样的事情
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php the_field('main_content_heading'); ?></h1>
<?php endwhile; endif; ?>
在循环中,使用the_field方法输出自定义字段。
在这里看到更多的细节:http://www.advancedcustomfields.com/resources/code-examples/
答
只需拨打同场的名称此功能在你的模板文件
<?php
while (have_posts()): the_post();
// Display post
if (have_posts()):?>
<?php echo the_field('slider_name');?>
<?php echo the_field('slider_description');
endif;
endwhile;
?>
请添加一些解释。目前,您的答案被标记为“低质量”,可能会被删除。 –