Add Theme Options to Artisteer 3 Theme

Have you ever wished you could make life easier for the users of your theme by giving them some custom Theme Options?  Well, here is how to do it in an Artisteer 3.0.0.39952 theme.  This technique might work with other versions, but I have not tested it on any others.

The easiest way is to use the OptionTree plugin.  Unfortunately, it conflicts with another plugin that I like to use.  Besides, if I can avoid using a plugin by using just a bit of code, it is usually worth it.

Artisteer creates a global array named $theme_options that stores all of the code to display Theme Options.  All we have to do is add our own options to that array.  To do that, you can code a function in your functions.php (in a child theme, right?) that will be added to the ‘admin_init’ action hook.

Here is a sample function that adds a text option to the Theme Options:


/*  Add unique Theme Options */
add_action('admin_init','mam_add_options');
function mam_add_options() {
   global $theme_options;
   $theme_options[] = array(
      'name' => __('Test Heading for My Options',THEME_NS),
      'type' => 'heading',
      'desc' => __('A description to go under the heading.',THEME_NS),
   );
   $theme_options[] = array(
      'id' => 'mam_test_text',
      'name' => __('A test text item',THEME_NS),
      'type' => 'text',
      'desc' => __('This is a description for the text item',THEME_NS),
   );
}

This code will add two items to the Theme Options panel:

  • A Header to separate the new options from the rest.
  • A one-line text item whose value can be retrieved later using the name mam_test_text.

You can examine the module options.php in the library subfolder of your theme to see examples of other types of options.

Now, to retrieve the options in your theme, just call the Artisteer function theme_get_option with the name of the theme as in this sample:


global $theme_options;
$my_text = (function_exists('theme_get_option')) ? theme_get_option('mam_test_text') : 'default value';

Now you can add as many options as you need to provide even more flexibility to your theme.

If you have questions, don’t hesitate to post a Reply, or use the ‘Contact Me‘ form to email me.

Leave a Reply

Your email address will not be published. Required fields are marked *

*