Add An Options Page To Your Theme With The NHP Theme Options Framework

The NHP Theme Options Framework is an easy to use free options framework from Freelance Graphic Designer Lee Mason.

On the framework home page Lee acknowledges other great option frameworks such as Options Framework Theme and The UpThemes Framework though points out that neither of them provided him with the extendibility he needed. Specifically he wanted:

  • Section Tabs – Each settings section to have its own “tab” which can be clicked through.
  • Use the WordPress Core Settings API – The settings to use the core WordPress functions for creating/editing settings (no point reinventing the wheel).
  • Custom Error Handling – To be able to display error totals and custom messages for each section/setting.
  • Easily Extendable – To be able to extend the framework for custom use applications, settings fields and custom validation.
  • Customisable – To be able to customise the functionality and style without hacking at the core.

NHP Theme Options Framework

Adding the options to a theme is incredibly easy. You first need to upload the theme-options.php file and options directory to your theme folder (e.g. www.yoursite.com/wp-content/themes/twentyeleven/themeoptions.php and www.yoursite.com/wp-content/themes/twentyeleven/options). Then you need to request the theme-options.php file from your theme via your theme functions.php file.

require( dirname( __FILE__ ) . '/theme-options.php' );

Once you have added the above line to your theme functions file, you will see a new Theme Options page underneath your appearance section. The framework supports a 28 field types including textareas, check boxes, dates, colours, post type selector and info field.

NHP Text Fields

The framework includes lots of validation classes such as no HTML, date validation, colour validation and string replacement.

NHP Custom Fields

The framework comes with an import and export system built in so that users can save what their configurations.

NHP Import & Export

A number of custom message phrases are included with the framework such as ‘Settings Saved’ and ‘Settings Imported’.

NHP Error Messages

I’ve not developed a theme with a custom options page so I am not in a position to compare it to other option frameworks out there. It does appear to be a very good option though due to it’s flexibility and number of field types to choose from. The code has comments throughout and it is well documented too so you shouldn’t have difficulties modifying it for your own website theme.

More information can be found at the link below.

Thanks,
Kevin

Link: NHP Theme Options Framework

This article was authored by:

Kevin Muldoon is a professional blogger with a love of travel. He writes regularly about topics such as WordPress, Blogging, Productivity, Internet Marketing and Social Media on his personal blog and and provides technical support at Rise Forums. He can also be found on Twitter: @KevinMuldoon and Google+.

Kevin Muldoon has authored 830 posts.Visit Website

Showing 2 Comments

  • This is quite interesting, will add options panel to my basic wp theme.

    REPLY
  • I always loved NHP… unfortunately, it hasn’t seen development in six months and the bugs and feature requests have been piling up. As a result, I got tired of watching problems go unsolved, forked NHP, and released my own framework which resolves most of the issues people had with NHP and adds a few features of my own! If you want to take a look at my continuation of NHP, check out https://github.com/ghost1227/Redux-Framework/

    REPLY

Add Your Voice: