• Resolved herrschuessler

    (@herrschuessler)


    I added a field group to the location Post Type Archive but cannot get the saved values from those fields via get_field( '{post-type}_archive', 'option' ); – the return value is always null.

    I noticed that ACF saves options to the database table wp_option with the prefix options_, this prefix is missing from the variables that are saved on the ACFE post type archive settings page. Could this be a bug?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    The ACF Extended Post Type Archive feature save the field values in the post id {post-type}_archive instead of option.

    To retrieve field data, you have to use get_field('my_field', 'my-post-type_archive').

    Regards.

    Thread Starter herrschuessler

    (@herrschuessler)

    Hi Konrad,

    thanks for clearing that up! Do you have any plans on expanding the documentation of your project beyond the description in the plugin directory?

    Best regards
    Christoph

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Absolutely, and I can also tell you that I’m currently working on it 🙂

    It should be out during the summer!

    Have a nice day.

    Regards.

    Thread Starter herrschuessler

    (@herrschuessler)

    Great, good to know! Thanks for your great work with this plugin!

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    BTW,

    In your Post type Archive & Single template files, you can use the following code in order to automatically retrieve fields from the Archive options Page:

    
    <?php if(have_archive()): ?>
        <?php while(have_archive()): the_archive(); ?>
        
            <?php 
    
            // Retrieve 'my_field' from 'my-post-type_archive' Archive Page
            $my_field = get_field('my_field');
    
            ?>
        
        <?php endwhile; ?>
    <?php endif; ?>
    

    When you’re inside that while(have_archive()): the_archive(); loop, you don’t need to add the Option Post ID, like that get_field('my_field', 'my-post-type_archive');.

    It will be automatically added for you!

    Regards.

    Hi!

    Is it possible that these custom fields can be displayed within templates created in elementor? I can currently apply a file template, but custom fields are not shown through Elementor dynamic options unless I build a shortcode to show them.

    Regards

    And another question, how to add Rankmath metabox for this admin page anchage Archive label to a custom label name ?

    • This reply was modified 3 years, 9 months ago by sermalefico.
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Unable to retrieve post type archive fields’ is closed to new replies.