Php 在博客存档页面上显示ACF
我需要在博客存档页面上显示一些额外的信息,但无法将其编码,因为其他人必须能够编辑这些信息 我在此页面上添加了一些自定义字段,但无法在实际页面上显示它们。 有办法解决这个问题吗 我的代码:Php 在博客存档页面上显示ACF,php,wordpress,advanced-custom-fields,acfpro,Php,Wordpress,Advanced Custom Fields,Acfpro,我需要在博客存档页面上显示一些额外的信息,但无法将其编码,因为其他人必须能够编辑这些信息 我在此页面上添加了一些自定义字段,但无法在实际页面上显示它们。 有办法解决这个问题吗 我的代码: <div class="save_the_date"> <?php if( have_rows('actiedagen') ): while ( have_rows('actiedagen') ) : the_row(); the_sub
<div class="save_the_date">
<?php
if( have_rows('actiedagen') ):
while ( have_rows('actiedagen') ) : the_row();
the_sub_field('actiedagen_titel');
the_sub_field('actiedagen_datum');
the_sub_field('actiedagen_locatie');
endwhile;
else :
endif;
?>
</div>
您可以添加用于编辑这些字段的选项页:
if (function_exists('acf_add_options_page')) {
acf_add_options_page(array(
'page_title' => 'Theme General Settings',
'menu_title' => 'Theme Settings',
'menu_slug' => 'theme-general-settings',
'capability' => 'edit_posts',
'redirect' => false
));
}
然后在此选项页上显示此字段组
至于显示值,您需要添加第二个参数“option”,如下所示:
<?php
if( have_rows('actiedagen', 'option') ):
while ( have_rows('actiedagen', 'option') ) : the_row();
the_sub_field('actiedagen_titel'); // no need to add option here
the_sub_field('actiedagen_datum');
the_sub_field('actiedagen_locatie');
endwhile;
else :
endif;
?>