Get values from an options page

Last updated Jun 30, 2022


All the template functions (get_field, the_field, etc) can be used to load values from an options page, however, a second parameter is required to target the options page. This is similar to passing through a $post_id parameter to target a specific post object.

The $post_id parameter needed is a string containing the word ‘option’ or ‘options’.

Please note that although it is possible to create multiple options pages, all values are saved and loaded using ‘option’ as the $post_id.


Display a field

<p><?php the_field('field_name', 'option'); ?></p>

Retrieve a field


$variable = get_field('field_name', 'option');

// do something with $variable


Display a sub field

Note that when inside of a have_rows loop, you do not need to use the $post_id parameter for any sub field functions (get_sub_field, the_sub_field)

<?php if( have_rows('repeater_field_name', 'option') ): ?>


    <?php while( have_rows('repeater_field_name', 'option') ) : the_row(); ?>

        <li><?php the_sub_field('title'); ?></li>

    <?php endwhile; ?>


<?php endif; ?>