Support

Account

Home Forums Add-ons Options Page Option field value not loading on Archive page

Solved

Option field value not loading on Archive page

  • Option field values are not loading on my site’s archive template. I tried using get_option(‘page_for_posts’) without success. Maybe because the fields are 1. options and 2. part of a repeater and 3. in the footer? I can provide a link if needed. Thank you!

  • Hi FrankiesFolio,

    In order to get an option field from an ACF Options Page, you need to use the string ‘option’ as the $post_id parameter in your get_field() call. How to get values from an options page documentation.

    The location of the call in your templates should not matter.

    Here is some sample code to get values from an options page repeater:

    
    <?php if( have_rows('repeater-field-name-or-field-key', 'option') ): ?>
        <ul>
        <?php while( have_rows('repeater-field-name-or-field-key', 'option') ): the_row(); ?>
            <li><?php the_sub_field('page_for_posts'); ?></li>
        <?php endwhile; ?>
        </ul>
    <?php endif; ?>
    

    ————————————————–

    Help your fellow forum-goers and moderation team; if a response solves your problem, please mark it as the solution. Thank you!

  • Thank you for the quick response. The option values appear on the footer of every page/post EXCEPT the archive.php template, which leads me to believe the problem is similar to this FAQ. I cannot figure out how to get this solution to work because I am dealing with option page fields + sub fields.

    I think the code is fine, please see below.

    <div class="section group">
                	<?php if( have_rows('footer_widgets', 'option') ): ?>
    				<?php while( have_rows('footer_widgets', 'option') ): the_row(); ?>                
                        <div class="col span_1_of_2">                        
                            <h2><?php the_sub_field('heading'); ?></h2>
                            <?php the_sub_field('description'); ?>
                            <a href="<?php the_sub_field('button_link'); ?>" class="footer-cta-btn"><?php the_sub_field('button_name'); ?></a> 
                        </div>                 
                   <?php endwhile; ?>
                   <?php endif; ?>
                   </div>
  • This reply has been marked as private.
  • Your code is indeed fine. I setup an options page and checked the February blog archive, and it most definitely shows the options page repeater fields using your above code and field names within footer.php. Nor can I think of a reason why that wouldn’t work purely based on ACF…

    Perhaps there is a conditional somewhere in your footer.php that is preventing the above code from executing at all? Have you verified that it gets to the first have_rows() call by outputting something unconditionally, such as

    <pre><?php echo 'Where are my options!?'; ?></pre>
    <div class="section group">
                	<?php if( have_rows('footer_widgets', 'option') ): ?>
    				<?php while( have_rows('footer_widgets', 'option') ): the_row(); ?>                
                        <div class="col span_1_of_2">                        
                            <h2><?php the_sub_field('heading'); ?></h2>
                            <?php the_sub_field('description'); ?>
                            <a href="<?php the_sub_field('button_link'); ?>" class="footer-cta-btn"><?php the_sub_field('button_name'); ?></a> 
                        </div>                 
                   <?php endwhile; ?>
                   <?php endif; ?>
                   </div>

    Or perhaps your archive template is calling a different footer template entirely, using get_footer( $name ) which loads footer-name.php.

    ——————————-

    Help your fellow forum-goers and moderation team; if a response solves your problem, please mark it as the solution. Thank you!

  • It looks to be a plugin conflict with tags and categories, you are correct that date, author, etc. archives are functioning properly. If I figure out a fix I will post here. Thanks!

  • What is the name/URL of the plugin that is conflicting? I’d love to take a look myself 🙂

  • That would be awesome! The plugin is WP Download Manager and it seems to be an issue with the main query. If I use wp_query the ACF fields will return a value. Unfortunately I can’t use wp_query on an archive and have functioning pagination.

    I posted to the WP Download Manager forum as well. Thank you for all your help. Should I mark as resolved since the issue isn’t technically with ACF?

  • Let’s hold off on that a little bit in case we can find a fix for other users of WP Download Manager in conjunction with ACF. 🙂

    Could you provide a URL to this plugin and a URL to its forums? I’m having a hard time figuring out which WP Download Manager you are referring to (there are apparently several with similar names)!

    Thanks!

  • Here’s the plugin website: http://www.wpdownloadmanager.com/ I have WP Download Manager PRO version. And here is the forum: http://www.wpdownloadmanager.com/support/forum/download-manager-pro/

    Thanks again!

  • It requires purchase to download or see the forums 🙁

    I do not have that plugin unfortunately, so I cannot look at what it is doing that might interfere with ACF. I doubt it would be legal to give me a copy for debugging purposes either.

    In the meantime, I do not see anything special being done with WP_Query when the post_id is ‘option’, so I’m not sure how changing to WP_Query would alter how ACF handles have_rows( ‘something’, ‘option’ )…

  • I really appreciate your efforts to look into this further! I think it comes down to a conflict between the theme and the WP Download Manager. ACF continues to be a terrific plugin, I use it on all my sites.

  • Not wanting to crash this thread, just to notify you that I have also had this exact problem. Nothing fancy, not part of a repeater. Just some image upload options that were used in the header and the footer.

    Worked everywhere (including CPTs) but not on archive/category pages of normal posts.

    Disabled all plugins, still the same. Tried it with Image Objects and Image urls. On the archive pages it was returning the Image ID on archive/category rather than the url. In the end rather than try to work around it I just changed image upload to url instead which works fine.

    I’m not sure this helps much but filing it anyway in case it might.

    Thanks!

  • Hello, I have the same problem on the website i currently develop, is there any solution yet? I have a Google Maps in my Footer with multiple markers which get loaded from a repeater on the options page. On every page, it works fine except on the archive page. I also deactivated all my other plugins, but the bug still exists…

  • Dear all,

    I’m currently having the same situation.

    Options does not show up on category.php
    But it did show up in index.php

    Any solution please? I followed exactly the example give but no avail.

    
                <?php 
    			if( have_rows('client_logo', 'option') ): 
    			?>
                    <?php while( have_rows('client_logo', 'option') ): the_row(); ?>
                		<img src="<?php the_sub_field('client_logo_image'); ?>" />
                    <?php endwhile; ?>
                <?php endif; ?>
    
  • Having the same problem. Image shows perfectly on every page except on tag.php, category.php and archive.php.

    <?php $logo = get_field('logo', 'option'); ?>
    <img id="logo" src="<?php echo $logo['url'];?>" alt="<?php echo $logo['alt']; ?>" title="<?php echo $logo['title']; ?>" />
  • Having a similar problem. I’m loading option page field values in my header.php file. They’re showing up on every archive page except tag archives

  • I realize this is a super old thread…anybody have any luck finding a solution?

  • encountering this as well. noticed my Option fields disappeared only when i added a custom post type to the general archive.

    function archive_include_cpt( $query ) {
        if( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
            $query->set( 'post_type', array( 'project', 'post' ));
            return $query;
        }
    }
    add_filter( 'pre_get_posts', 'archive_include_cpt' );

    (via)

    maybe this is helpful? bummer this thread is marked as solved. perhaps i’ll start another?

Viewing 19 posts - 1 through 19 (of 19 total)

The topic ‘Option field value not loading on Archive page’ is closed to new replies.