【发布时间】:2016-06-13 16:19:31
【问题描述】:
我已经安装了一个高级自定义字段插件来在帖子中上传音频和图像文件。每个帖子包含 5 个字段
我可以发布帖子,但我不知道如何检索 wordpress 模板页面中的每个字段
【问题讨论】:
标签: php html mysql wordpress advanced-custom-fields
我已经安装了一个高级自定义字段插件来在帖子中上传音频和图像文件。每个帖子包含 5 个字段
我可以发布帖子,但我不知道如何检索 wordpress 模板页面中的每个字段
【问题讨论】:
标签: php html mysql wordpress advanced-custom-fields
只需使用模板文件中的字段名称调用此函数
<?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;
?>
【讨论】:
你可以这样做
<?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/
【讨论】: