Home Forums General Issues Optimizing Data from Options Pages


Optimizing Data from Options Pages

  • In the theme I have been building I use several options pages for storing data not related to a specific post type. This includes data displayed in the site header and footer (contact information including mailing address, email addresses, phone numbers, social media links etc) and featured content for the home page or for various custom post type archive templates. For example the home page pulls from an options page with two relationship fields that allow content editors to select posts of different custom post types to feature on the home page. Similarly the archive templates pull from an options page with a relationship field allowing content editors to choose a specific post to feature at the top of the template.

    For pulling the data into the templates I am just using the get_field function. For example:

    get_field('my_options_field', 'options');

    From the ACF documentation I noted the data for the options pages is stored in the wp_options table. In looking to improve the performance speed of my template, is there anything I should be doing to optimize this data so that it is displayed efficiently?

    A few questions regarding this issue:

    1. Particularly for the data displayed in the header and footer, is there anything I should be doing so that the data is only queried from the database on the first page loaded then stored locally for re-display on subsequent page loads? For example putting the contact information into a cookie or PHP Session or is there something similar to a stored procedure that could be used?
    2. For the featured content I use the get_field function to retrieve the relationship field, then use a foreach loop with setup_postdata to display the featured post(s). Is there anything I should be doing to get the foreach loop to load each post as efficiently as possible or can the results be cached in the short term as the content is unlikely to change during a single site visit?
    3. Is there any steps I should be taking with the wp_options table to ensure that the data from the options pages can be loaded efficiently (such as setting up an index for the table etc)?

    Thank you in advance for any suggestions!


    P.S. In the theme I use the the acf-json feature to store my field groups.

  • Hi trebor,

    Something you can do when registering a page is, within the arguments passed to acf_add_options_page( [$settings] ); to set 'autoload' => true,. This way WordPress will have loaded these options for you already on page loads.

    More here:


  • With options pages the only real solution without a lot of codeing is the one posted by @nils-henrik setting autoload to true for the options page.

    There is another option, but it is more involved. You can save options pages to post meta table instead of options table. This can be done by specifying a post ID for the options page ID. But you would basically need to set up a custom post type where you could save your values. But something like this would need to be done before any data was saved into the options because moving the existing data would be very difficult.

  • Another alternative exists, although it is more complex. Instead of saving options pages to the options table, you may save them to the post meta table.

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

You must be logged in to reply to this topic.