I have installed Advanced Custom Fielts, and I have created custom fields such as email, phone etc. I put those in my footer.php, and the data is displayed only on the homepage. Can I use ACF to create global variables? My rule for that custom field is 'If Post Type is equal to post';

I get that data in footer.php like this

$phone_number = get_field('phone_number');

and Im displaying it like

<?php echo $phone_number; ?>

So basically when Im on my homepage, it is displayed correctly, when I go to other page(which has that same footer), data is not displayed. What can I do to display it on all pages?

3 Answers 3


You Need to use ACF Options Page plugin as well.

This Plugin has been deleted from the repository. Now you can use the function without the plugin.

The options page feature provides a set of functions to add extra admin pages and all data saved on an options page is global.

Sea the plugin overview

After installing plugin you have to add the following to your functions.php

if( function_exists('acf_add_options_page') ) {

and the "Options" label will be visible in your admin area.

then you just need to create acf fields with the rule like 'If Options Page is equal to Options'

Finally to display the field:

echo get_field('phone_number', 'option');
  • 1
    Thats wrong. You do not need any plugin for the acf options.
    – GDY
    Nov 30, 2017 at 15:07
  • What? what's wrong? Nov 30, 2017 at 15:08
  • He talk about global options and for global option you NEED plugin Nov 30, 2017 at 15:08
  • 1
    Theres no need for that plugin. With acf_add_options_page you create the page with get_field('xyz', 'option') you get the option.
    – GDY
    Nov 30, 2017 at 15:10
  • The options page feature provides a set of functions to add extra admin pages to edit ACF fields! Each admin page can be fully customized (see code examples below), and sub admin pages can be created too! All data saved on an options page is global. This means it is not attached to any particular post or page, but is saved in the wp_options table. This allows the data to be displayed on any page throughout the website (good for header and footer data)! Nov 30, 2017 at 15:11

As other users mention to create global options you need to have ACF Options Page add-on or ACF PRO. This will give you possibility to create nice options page and retrive your field in standard way:

$phone_number = get_field( 'phone_number', 'option' );

However there is a trick you can use to retrive your fields on every page.

If your options are working only on homepage I'm assuming you created custom fields on your homepage administration page. To retrive this fields on other pages pass your homepage ID as second argument.

$homepage_id = get_option('page_on_front');

$phone_number = get_field( 'phone_number', $homepage_id );
  • I will vote up your answer due to my similar answer got voted down unfairly Nov 30, 2017 at 19:37

That is because you're setting the field value as a post_meta value.

To achieve what you're trying to achieve, you need to create an options page. See: https://www.advancedcustomfields.com/resources/options-page/

That will allow you to display data globally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.