Home › Forums › General Issues › 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:
Thank you in advance for any suggestions!
-Robert
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: https://www.advancedcustomfields.com/resources/acf_add_options_page/
Cheers,
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.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.