0

I am trying to set up a settings page for my wordpress theme (developed it in roots.io using Trellis and Sage etc).

I have found a lot of really good documentation on how to use the settings API, for example: https://wpshout.com/making-an-admin-options-page-with-the-wordpress-settings-api/ or http://qnimate.com/wordpress-settings-api-a-comprehensive-developers-guide/ and a few others.

So lets say that I want a theme option page, this code should do it:

add_action( 'admin_menu', 'NEW_admin_add_page' );
function NEW_admin_add_page() {
    add_options_page(
        'Theme settings Page',
        'Theme settings',
        'manage_options',
        'nts',
        'nts_options_page'
    );
}

Should create a new page, but where within my theme do I add this code to ensure that when you load this theme (or when it loads if that is the right thing) this page turns up.

vrghost
  • 1,084
  • 2
  • 19
  • 42

1 Answers1

0

Found it, just add it to functions.php seems to do the trick :) Strangely enough it was not until the tenth article I read that someone thought to mention this :)

https://code.tutsplus.com/tutorials/the-wordpress-settings-api-part-2-sections-fields-and-settings--wp-24619

vrghost
  • 1,084
  • 2
  • 19
  • 42