While Pinegrow WP offers a really convenient way to setup all the WordPress actions directly from your HTML templates, there comes times when a web developer needs a bit of organization in his workflow, not only because such an approach is cleaner, but also for maintenance and evolution purposes. It’s always a good idea to consider solutions that can definitely ease your job.
Why create a settings page?
As we have seen in Kyeong Jun Lee interview, there is a very smart technique to free your template from the global WordPress settings like the Custom Post types action, the Customizer sections, the Taxonomies, the Register Sidebars action and the scripts & CSS enqueuing. We call it the Settings Page.
So basically, a Settings Page is a configuration file that is not part of the theme but that serve to setup all the features that are not related to one specific template but to the whole theme. During the theme export, these settings end up in the functions.php file.
Before starting a settings page, be sure to read How to start your WordPress theme development with Pinegrow WP. A clear vision about how your theme will be structured is the key to success for such a technique.
It is recommended to start your settings page before adding any WordPress actions other than WordPress site in your HTML template.
How to create a settings page?
For this tutorial, we consider that you already have created your theme master page.
First, create a blank page and save it with the name functions.html (or any name of your choice). From the Framework & Plugin Manager (menu File > Manage Frameworks) activate WordPress.
From the tree, select the Body element of the page and add WordPress Site.
You are now ready to configure the options:
- Use master page: index.html <- This is the name of your existing master page
- Preview page url: not needed
- Don’t export this page: checked
While the functions.html page itself will not be exported, the WordPress settings will be applied to the functions.php file which is automatically generated during an export.
You can now setup your sections and for that, you can use a very basic HTML structure. There’s no need for a complicated design, the idea is to clearly visualize and access your different settings.
You can decide of any presentation you want, the settings page is not public and will not be viewed in a browser. It is just meant to provide you with a way to set and maintain your global theme settings from Pinegrow.
You can create as many sections as the type of features that you plan to use. In each section, you create lists with the elements corresponding to the needs of your theme.
For example: If you plan to use 3 different custom post types, your create a Custom Post Types section and in that section, from the LIB panel, you add a standard list in which you simply enter the names of the 3 post types.
Then, for each of the 3 items from the list, you add the Register post type action and configure the settings just like you usually do when you work directly from the HTML template.
Note: Loops and custom WP queries remain in your HTML theme template.
You can do the same for the Customizer sections:
If you plan to provide 12 different customizer sections (yes, it is huge!) your can create dedicated section in which you enter the names of the sections.
Then, for each of the 12 sections, you add the Add customizer section action and configure the settings just like you usually do when you work directly from the HTML template.
Note: Customizer controls remain in your HTML theme template.
And the process is the very same for Taxonomies, Sidebars and scripts & CSS enqueuing.
What to do when the Settings page is done?
Once your settings page is ready, you can start to add WordPress actions as usual in your HTML theme template. From now on, if you must add a global feature or if you want to modify an existing one, you’ll need to go through your settings page. You will not have to dig anymore in complicated templates structures to find the action you really need to update or eventually remove 🙂
Note: If you join our Course on UDEMY, you’ll find a bonus demo video dedicated to that particular topic. (Check for Section 4 – Bonus Tracks)
If you want to discuss about this useful technique with other Pinegrow users, feel free to join us on the #slack community.
Last updated on February 14, 2017 at 10:08 pm