Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在博客存档页面上显示ACF_Php_Wordpress_Advanced Custom Fields_Acfpro - Fatal编程技术网

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;
    ?>