在博客存档页面上显示 ACF

Display ACF on blog archive page

我需要在博客存档页面上显示一些额外的信息,但无法将其编码,因为其他人必须能够编辑这些信息。

我在此页面上添加了一些自定义字段,但无法在实际页面上显示它们。 有什么办法解决这个问题吗?

我的代码:

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