{"id":1451,"date":"2009-12-19T20:16:23","date_gmt":"2009-12-20T01:16:23","guid":{"rendered":"http:\/\/judykat.com\/ken\/?p=1451"},"modified":"2012-03-31T20:41:46","modified_gmt":"2012-04-01T00:41:46","slug":"how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields","status":"publish","type":"post","link":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/","title":{"rendered":"How to add an options form to a wordpress theme using settings_fields"},"content":{"rendered":"<p>I spent some time today modifying a <a href=\"http:\/\/codex.wordpress.org\/Using_Themes\">WordPress theme<\/a> to take configuration properties. <\/p>\n<p>I want one theme that I can quickly re-configure to  create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I&#8217;d love to share one instance of the theme across these different instances. <\/p>\n<p>We&#8217;re using enough different plugins that <a href=\"http:\/\/mu.wordpress.org\/\">WordPress Mu<\/a> isn&#8217;t yet worth fighting. So database options and the <a href=\"http:\/\/codex.wordpress.org\/Settings_API\">Settings API<\/a> seemed the best way.<\/p>\n<p>The documentation on how to extend a theme this way is not so easy to find but there are plenty of examples. They tend to break the process into steps but don&#8217;t give as much sense of what you actually get and how to use it.<\/p>\n<p>I based my code on this example: <span class=\"removed_link\" title=\"http:\/\/blog.starscapetheme.com\/2008\/05\/31\/create-settings-page-for-theme\/\">http:\/\/blog.starscapetheme.com\/2008\/05\/31\/create-settings-page-for-theme\/<\/span><\/p>\n<p>After the fact, I found this description which seems well written: <span class=\"removed_link\" title=\"http:\/\/www.pixelace.com\/2009\/theme-options-for-wordpress-27\/\">http:\/\/www.pixelace.com\/2009\/theme-options-for-wordpress-27\/<\/span><\/p>\n<p>I created a menu item and a corresponding properties form:<\/p>\n<div style=\"clear:both;\">\n<img decoding=\"async\" alt=\"Wordpress Theme Options Form\" src=\"http:\/\/judykat.com\/ken-judy\/wp-content\/uploads\/public\/blogimages\/Screen-shot-2009-12-19-at-7.22.57_PM.png\" title=\"Wordpress Theme Options Form\" class=\"alignright\" width=\"365\" \/><img loading=\"lazy\" decoding=\"async\" alt=\"Wordpress Theme Menu Item\" src=\"http:\/\/judykat.com\/ken-judy\/wp-content\/uploads\/public\/blogimages\/Screen_shot_2009-12-19_at_7.22.43_PM.png\" title=\"Wordpress Theme Menu Item\" class=\"alignleft\" width=\"163\" height=\"148\" \/>\n<\/div>\n<div style=\"clear:both;\">&nbsp;<\/div>\n<p>My form adds three properties which are stored in the WordPress wp_options table and easily exposed on template pages<\/p>\n<p><code>&lt;link rel=\"stylesheet\" href=\"&lt;?php $options = get_option('vertical'); echo $options['vertical_custom_css_url']; ?&gt;\" type=\"text\/css\" media=\"screen\" \/&gt;<\/code><\/p>\n<p>Here&#8217;s the actual code I added to the functions.php page of the theme. If you don&#8217;t have a functions.php you can just create one in your theme folder. You need to make sure the code below is wrapped in &#8220;&lt;?php&#8221;  &#8220;?&gt;&#8221; tags.<\/p>\n<div style=\"background-color:black;color:white;white-space:pre;width: 550px; overflow: auto; padding: 5px;font-size:11px;font-family:courier new, monospace;\"><span style=\"color:gray;\">\/\/encapsulate the logic into a class<\/span><br \/>$cpanel = new ControlPanel();<\/p>\n<p><span style=\"color:yellow;\">class<\/span> <span style=\"color:orange;\">ControlPanel<\/span> {<br \/>  <span style=\"color:gray;\">\/* static array to contain default values<br \/>     the values set an additional css to override standard css in the theme<br \/>     as well as an image and link that is rendered in the sidebar. These<br \/>     three settings allow me to use the same theme with minor variations<br \/>     on different blogs on different topics but with very similar looks and feels *\/<\/span><br \/>  <span style=\"color:yellow;\">var<\/span> $default_settings = Array(<br \/>    <span style=\"color:#6f0;\">&#8216;vertical_custom_css_url&#8217;<\/span> =&gt; <span style=\"color:#6f0;\">&#8221;<\/span>,<br \/>    <span style=\"color:#6f0;\">&#8216;topic_banner_img&#8217;<\/span> =&gt;  <span style=\"color:#6f0;\">&#8216;\/images\/banner.jpg&#8217;<\/span>,<br \/>    <span style=\"color:#6f0;\">&#8216;topic_url&#8217;<\/span> =&gt;  <span style=\"color:#6f0;\">&#8216;http:\/\/www.judykat.com\/ken&#8217;<\/span><\/p>\n<p>  );<br \/>  <span style=\"color:gray;\">\/\/constructor<\/span><br \/>  <span style=\"color:yellow;\">function<\/span> <span style=\"color:orange;\">ControlPanel()<\/span> <br \/>  {<br \/>    <span style=\"color:gray;\">\/\/hook to add a menu item in the Theme&#8217;s area of the admin sidebar<\/span><br \/>    add_action(<span style=\"color:#6f0;\">&#8216;admin_menu&#8217;<\/span>, array(<span style=\"color:yellow;\">&amp;<\/span>$this, <span style=\"color:#6f0;\">&#8216;vertical_admin_menu&#8217;<\/span>));<br \/>    <span style=\"color:gray;\">\/* if options are not already created in the database, add them and set to default values<br \/>       this creates a single database entry in wp_options with key vertical and <br \/>       values a hash of key\/value pairs *\/<\/span><br \/>    <span style=\"color:yellow;\">if<\/span> (<span style=\"color:yellow;\">!<\/span>is_array(get_option(<span style=\"color:#6f0;\">&#8216;vertical&#8217;<\/span>)))<br \/>      add_option(<span style=\"color:#6f0;\">&#8216;vertical&#8217;<\/span>, $this-&gt;default_settings);<br \/>    <span style=\"color:gray;\">\/\/load the existing options into an array accessible as a property of this instance of ControlPanel<\/span><br \/>    $this-&gt;options = get_option(<span style=\"color:#6f0;\">&#8216;vertical&#8217;<\/span>);<br \/>  }<br \/>     <span style=\"color:gray;\">\/\/the function that ties an html form to the hook defined in the constructor.<\/span><br \/>  <span style=\"color:yellow;\">function<\/span> vertical_admin_menu() {<br \/>      add_theme_page(<span style=\"color:#6f0;\">&#8216;Vertical Theme Control Panel&#8217;<\/span>, <span style=\"color:#6f0;\">&#8216;Customize Theme&#8217;<\/span>, <span style=\"color:#6f0;\">&#8216;edit_themes&#8217;<\/span>, <span style=\"color:#6f0;\">&#8220;vertical&#8221;<\/span>, array(<span style=\"color:yellow;\">&amp;<\/span>$this, <span style=\"color:#6f0;\">&#8216;vertical_theme_page&#8217;<\/span>));<br \/>  }<br \/>  <span style=\"color:gray;\">\/\/function that defines the form for viewing and setting properties for the theme.<\/span><br \/>  <span style=\"color:yellow;\">function<\/span> vertical_theme_page() {<br \/>      <span style=\"color:gray;\">\/\/if the form is being submitted, update the options in the database<\/span><br \/>    <span style=\"color:yellow;\">if<\/span> ( isset( $_POST[<span style=\"color:#6f0;\">&#8216;submit&#8217;<\/span>] ) ) {<br \/>      <span style=\"color:gray;\">\/\/if the <span style=\"color:#6f0;\">&#8220;Save Changes&#8221;<\/span> button was clicked, set the user entered values from the form<\/span><br \/>      <span style=\"color:yellow;\">if<\/span> (<span style=\"color:#6f0;\">&#8216;Save Changes&#8217;<\/span> <span style=\"color:yellow;\">==<\/span> $_POST[<span style=\"color:#6f0;\">&#8216;submit&#8217;<\/span>]) {<br \/>        $this-&gt;options[<span style=\"color:#6f0;\">&#8220;vertical_custom_css_url&#8221;<\/span>] = $_POST[<span style=\"color:#6f0;\">&#8216;vertical_custom_css_url&#8217;<\/span>];<br \/>        $this-&gt;options[<span style=\"color:#6f0;\">&#8220;topic_banner_img&#8221;<\/span>] = $_POST[<span style=\"color:#6f0;\">&#8216;topic_banner_img&#8217;<\/span>];<br \/>        $this-&gt;options[<span style=\"color:#6f0;\">&#8220;topic_url&#8221;<\/span>] = $_POST[<span style=\"color:#6f0;\">&#8216;topic_url&#8217;<\/span>];<br \/>        $state=<span style=\"color:#6f0;\">&#8220;saved&#8221;<\/span>;<br \/>      } <span style=\"color:gray;\">\/\/else if <span style=\"color:#6f0;\">&#8220;Defaults&#8221;<\/span> was clicked, reset values to default<\/span><br \/>      <span style=\"color:yellow;\">else<\/span> <span style=\"color:yellow;\">if<\/span> (<span style=\"color:#6f0;\">&#8216;Defaults&#8217;<\/span> <span style=\"color:yellow;\">==<\/span> $_POST[<span style=\"color:#6f0;\">&#8216;submit&#8217;<\/span>]) {<br \/>        $this-&gt;options[<span style=\"color:#6f0;\">&#8220;vertical_custom_css_url&#8221;<\/span>] = $this-&gt;default_settings[<span style=\"color:#6f0;\">&#8216;vertical_custom_css_url&#8217;<\/span>];<br \/>        $this-&gt;options[<span style=\"color:#6f0;\">&#8220;topic_banner_img&#8221;<\/span>] = $this-&gt;default_settings[<span style=\"color:#6f0;\">&#8216;topic_banner_img&#8217;<\/span>];<br \/>        $this-&gt;options[<span style=\"color:#6f0;\">&#8220;topic_url&#8221;<\/span>] = $this-&gt;default_settings[<span style=\"color:#6f0;\">&#8216;topic_url&#8217;<\/span>];<br \/>        $state=<span style=\"color:#6f0;\">&#8220;reverted to defaults&#8221;<\/span>;<br \/>      } <span style=\"color:gray;\">\/\/commit the changes to the database<\/span><br \/>      update_option(<span style=\"color:#6f0;\">&#8216;vertical&#8217;<\/span>, $this-&gt;options);<br \/>      <span style=\"color:gray;\">\/\/render a status message  of the above actions in the standard WordPress admin dialog box at the top of the form.<\/span><br \/>      echo &#8216;<span style=\"color:#8DA6CE;\">&lt;div class=<span style=\"color:#6f0;\">&#8220;updated fade&#8221;<\/span> id=<span style=\"color:#6f0;\">&#8220;message&#8221;<\/span> style=<span style=\"color:#6f0;\">&#8220;background-color: rgb(255, 251, 204); width: 300px; margin-left: 20px&#8221;<\/span>&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;p&gt;<\/span>Settings <span style=\"color:#8DA6CE;\">&lt;strong&gt;<\/span>&#8216;.$state.&#8217;<span style=\"color:#8DA6CE;\">&lt;\/strong&gt;<\/span>.<span style=\"color:#8DA6CE;\">&lt;\/p&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;\/div&gt;<\/span>&#8216;;<br \/>    }<br \/>    <span style=\"color:gray;\">\/\/the actual html form in standard markup to appear standard in the WordPress Admin<\/span><br \/>    ?&gt;<br \/>    <span style=\"color:#8DA6CE;\">&lt;div class=<span style=\"color:#6f0;\">&#8216;wrap&#8217;<\/span>&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;h2&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;?php _e(<span style=\"color:#6f0;\">&#8216;Customize Vertical Theme&#8217;<\/span>); ?&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;\/h2&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;div id=<span style=\"color:#6f0;\">&#8220;header&#8221;<\/span>&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;div id=<span style=\"color:#6f0;\">&#8220;headwrap&#8221;<\/span>&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;div id=<span style=\"color:#6f0;\">&#8220;header&#8221;<\/span>&gt;<\/span><br \/>            <span style=\"color:#8DA6CE;\">&lt;div id=<span style=\"color:#6f0;\">&#8220;headerimg&#8221;<\/span>&gt;<\/span><br \/>              <span style=\"color:#8DA6CE;\">&lt;h1&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;?php bloginfo(<span style=\"color:#6f0;\">&#8216;name&#8217;<\/span>); ?&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;\/h1&gt;<\/span><br \/>              <span style=\"color:#8DA6CE;\">&lt;div class=<span style=\"color:#6f0;\">&#8220;description&#8221;<\/span>&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;?php bloginfo(<span style=\"color:#6f0;\">&#8216;description&#8217;<\/span>); ?&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;\/div&gt;<\/span><br \/>            <span style=\"color:#8DA6CE;\">&lt;\/div&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;\/div&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;\/div&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;\/div&gt;<\/span><br \/>    <span style=\"color:#8DA6CE;\">&lt;br&gt;<\/span><br \/>    <span style=\"color:#8DA6CE;\">&lt;form id=<span style=\"color:#6f0;\">&#8220;vertical-settings-form&#8221;<\/span> method=<span style=\"color:#6f0;\">&#8220;post&#8221;<\/span> action=<span style=\"color:#6f0;\">&#8220;&#8221;<\/span>&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;?php settings_fields( <span style=\"color:#6f0;\">&#8216;vertical-settings&#8217;<\/span> ); ?&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;table class=<span style=\"color:#6f0;\">&#8220;form-table&#8221;<\/span>&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;tr valign=<span style=\"color:#6f0;\">&#8220;top&#8221;<\/span>&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;th scope=<span style=\"color:#6f0;\">&#8220;row&#8221;<\/span>&gt;<\/span>Path to Vertical CSS file:<span style=\"color:#8DA6CE;\">&lt;\/th&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;td&gt;<\/span><br \/>            &lt;input size=<span style=\"color:#6f0;\">&#8220;70&#8221;<\/span> type=<span style=\"color:#6f0;\">&#8220;text&#8221;<\/span> name=<span style=\"color:#6f0;\">&#8220;vertical_custom_css_url&#8221;<\/span> id=<span style=\"color:#6f0;\">&#8220;vertical_custom_css_url&#8221;<\/span> value=<span style=\"color:#6f0;\">&#8220;<span style=\"color:#8DA6CE;\">&lt;?php echo $this-&gt;<\/span>options[&#8220;vertical_custom_css_url&#8221;]; ?&gt;&#8221;<\/span> \/&gt;<br \/>            <span style=\"color:#8DA6CE;\">&lt;br\/&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;small&gt;<\/span>example: &lt;?php echo(str_replace(get_bloginfo(<span style=\"color:#6f0;\">&#8216;url&#8217;<\/span>),<span style=\"color:#6f0;\">&#8220;&#8221;<\/span>,get_bloginfo(<span style=\"color:#6f0;\">&#8216;template_url&#8217;<\/span>).<span style=\"color:#6f0;\">&#8216;\/&#8217;<\/span>.str_replace(<span style=\"color:#6f0;\">&#8221; &#8220;<\/span>, <span style=\"color:#6f0;\">&#8220;-&#8220;<\/span>,strtolower(wptexturize(get_bloginfo( <span style=\"color:#6f0;\">&#8216;name&#8217;<\/span> )))))); ?&gt;\/style.css<span style=\"color:#8DA6CE;\">&lt;\/small&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;\/td&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;\/tr&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;tr valign=<span style=\"color:#6f0;\">&#8220;top&#8221;<\/span>&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;th scope=<span style=\"color:#6f0;\">&#8220;row&#8221;<\/span>&gt;<\/span>Path to Category Page:<span style=\"color:#8DA6CE;\">&lt;\/th&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;td&gt;<\/span><br \/>            &lt;input size=<span style=\"color:#6f0;\">&#8220;70&#8221;<\/span> type=<span style=\"color:#6f0;\">&#8220;text&#8221;<\/span> name=<span style=\"color:#6f0;\">&#8220;topic_url&#8221;<\/span> id=<span style=\"color:#6f0;\">&#8220;topic_url&#8221;<\/span> value=<span style=\"color:#6f0;\">&#8220;<span style=\"color:#8DA6CE;\">&lt;?php echo $this-&gt;<\/span>options[&#8220;topic_url&#8221;]; ?&gt;&#8221;<\/span> \/&gt;<br \/>            <span style=\"color:#8DA6CE;\">&lt;br\/&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;small&gt;<\/span>example: http:\/\/www.judykat.com\/ken<span style=\"color:#8DA6CE;\">&lt;\/small&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;\/td&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;\/tr&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;tr valign=<span style=\"color:#6f0;\">&#8220;top&#8221;<\/span>&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;th scope=<span style=\"color:#6f0;\">&#8220;row&#8221;<\/span>&gt;<\/span>Path to Category Banner:<span style=\"color:#8DA6CE;\">&lt;\/th&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;td&gt;<\/span><br \/>            &lt;input size=<span style=\"color:#6f0;\">&#8220;70&#8221;<\/span> type=<span style=\"color:#6f0;\">&#8220;text&#8221;<\/span> name=<span style=\"color:#6f0;\">&#8220;topic_banner_img&#8221;<\/span> id=<span style=\"color:#6f0;\">&#8220;topic_banner_img&#8221;<\/span> value=<span style=\"color:#6f0;\">&#8220;<span style=\"color:#8DA6CE;\">&lt;?php echo $this-&gt;<\/span>options[&#8220;topic_banner_img&#8221;]; ?&gt;&#8221;<\/span> \/&gt;<br \/>            <span style=\"color:#8DA6CE;\">&lt;br\/&gt;<\/span><span style=\"color:#8DA6CE;\">&lt;small&gt;<\/span>example: &lt;?php echo(str_replace(get_bloginfo(<span style=\"color:#6f0;\">&#8216;url&#8217;<\/span>),<span style=\"color:#6f0;\">&#8220;&#8221;<\/span>,get_bloginfo(<span style=\"color:#6f0;\">&#8216;template_url&#8217;<\/span>).<span style=\"color:#6f0;\">&#8216;\/&#8217;<\/span>.str_replace(<span style=\"color:#6f0;\">&#8221; &#8220;<\/span>, <span style=\"color:#6f0;\">&#8220;-&#8220;<\/span>,strtolower(wptexturize(get_bloginfo( <span style=\"color:#6f0;\">&#8216;name&#8217;<\/span> )))))); ?&gt;\/images\/banner.jpg<span style=\"color:#8DA6CE;\">&lt;\/small&gt;<\/span><br \/>          <span style=\"color:#8DA6CE;\">&lt;\/td&gt;<\/span><br \/>        <span style=\"color:#8DA6CE;\">&lt;\/tr&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;\/table&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;p class=<span style=\"color:#6f0;\">&#8220;submit&#8221;<\/span>&gt;<\/span><br \/>      &lt;input type=<span style=\"color:#6f0;\">&#8220;submit&#8221;<\/span> name=<span style=\"color:#6f0;\">&#8220;submit&#8221;<\/span> class=<span style=\"color:#6f0;\">&#8220;button-primary&#8221;<\/span> value=<span style=\"color:#6f0;\">&#8220;<span style=\"color:#8DA6CE;\">&lt;?php _e(&#8216;Save Changes&#8217;) ?&gt;<\/span>&#8220;<\/span> \/&gt;<br \/>      &lt;input type=<span style=\"color:#6f0;\">&#8220;submit&#8221;<\/span> name=<span style=\"color:#6f0;\">&#8220;submit&#8221;<\/span> class=<span style=\"color:#6f0;\">&#8220;button-primary&#8221;<\/span> value=<span style=\"color:#6f0;\">&#8220;<span style=\"color:#8DA6CE;\">&lt;?php _e(&#8216;Defaults&#8217;) ?&gt;<\/span>&#8220;<\/span> \/&gt;<br \/>      <span style=\"color:#8DA6CE;\">&lt;\/p&gt;<\/span><br \/>      <span style=\"color:#8DA6CE;\">&lt;input type=<span style=\"color:#6f0;\">&#8220;hidden&#8221;<\/span> name=<span style=\"color:#6f0;\">&#8220;saved&#8221;<\/span> value=<span style=\"color:#6f0;\">&#8220;true&#8221;<\/span>&gt;<\/span><br \/>    <span style=\"color:#8DA6CE;\">&lt;\/form&gt;<\/span><br \/>  <span style=\"color:#8DA6CE;\">&lt;\/div&gt;<\/span><br \/>  &lt;?php<br \/>  }<br \/>}<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I&#8217;d love &hellip; <a href=\"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[30],"tags":[687,109,101,108,107,96],"class_list":["post-1451","post","type-post","status-publish","format-standard","hentry","category-software-development","tag-html","tag-options","tag-php","tag-settings","tag-themes","tag-wordpress"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I&#039;d love to share one instance of the theme across these different instances. We&#039;re using enough different\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Ken Judy\"\/>\n\t<meta name=\"keywords\" content=\"html,options,php,settings,themes,wordpress,software development\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Ken  Judy | Building AI Solutions That Work and Coaching Leaders Through Change\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How to add an options form to a wordpress theme using settings_fields | Ken Judy\" \/>\n\t\t<meta property=\"og:description\" content=\"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I&#039;d love to share one instance of the theme across these different instances. We&#039;re using enough different\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2009-12-20T01:16:23+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2012-04-01T00:41:46+00:00\" \/>\n\t\t<meta property=\"article:author\" content=\"kenjudy\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How to add an options form to a wordpress theme using settings_fields | Ken Judy\" \/>\n\t\t<meta name=\"twitter:description\" content=\"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I&#039;d love to share one instance of the theme across these different instances. We&#039;re using enough different\" \/>\n\t\t<meta name=\"twitter:creator\" content=\"@kenjudy\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#article\",\"name\":\"How to add an options form to a wordpress theme using settings_fields | Ken Judy\",\"headline\":\"How to add an options form to a wordpress theme using settings_fields\",\"author\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/author\\\/ken\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/#person\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"http:\\\/\\\/judykat.com\\\/ken-judy\\\/wp-content\\\/uploads\\\/public\\\/blogimages\\\/Screen-shot-2009-12-19-at-7.22.57_PM.png\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#articleImage\"},\"datePublished\":\"2009-12-19T20:16:23-05:00\",\"dateModified\":\"2012-03-31T20:41:46-04:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#webpage\"},\"articleSection\":\"software development, html, options, php, settings, themes, wordpress\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/judykat.com\\\/ken-judy\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/category\\\/software-development\\\/#listItem\",\"name\":\"software development\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/category\\\/software-development\\\/#listItem\",\"position\":2,\"name\":\"software development\",\"item\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/category\\\/software-development\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#listItem\",\"name\":\"How to add an options form to a wordpress theme using settings_fields\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#listItem\",\"position\":3,\"name\":\"How to add an options form to a wordpress theme using settings_fields\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/category\\\/software-development\\\/#listItem\",\"name\":\"software development\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/#person\",\"name\":\"Ken Judy\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#personImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0afc45b1325360e0cc414a2f6a0f1e85cd1a41dfff008d3172b91fba8fac3de8?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Ken Judy\"},\"sameAs\":[\"kenjudy\",\"kenjudy\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/author\\\/ken\\\/#author\",\"url\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/author\\\/ken\\\/\",\"name\":\"Ken Judy\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/0afc45b1325360e0cc414a2f6a0f1e85cd1a41dfff008d3172b91fba8fac3de8?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Ken Judy\"},\"sameAs\":[\"kenjudy\",\"kenjudy\"]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#webpage\",\"url\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/\",\"name\":\"How to add an options form to a wordpress theme using settings_fields | Ken Judy\",\"description\":\"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\\\/graphic schemes. I want easy maintenance so I'd love to share one instance of the theme across these different instances. We're using enough different\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/author\\\/ken\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/author\\\/ken\\\/#author\"},\"datePublished\":\"2009-12-19T20:16:23-05:00\",\"dateModified\":\"2012-03-31T20:41:46-04:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/#website\",\"url\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/\",\"name\":\"Ken  Judy\",\"description\":\"Building AI Solutions That Work and Coaching Leaders Through Change\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/judykat.com\\\/ken-judy\\\/#person\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How to add an options form to a wordpress theme using settings_fields | Ken Judy","description":"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I'd love to share one instance of the theme across these different instances. We're using enough different","canonical_url":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/","robots":"max-image-preview:large","keywords":"html,options,php,settings,themes,wordpress,software development","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#article","name":"How to add an options form to a wordpress theme using settings_fields | Ken Judy","headline":"How to add an options form to a wordpress theme using settings_fields","author":{"@id":"https:\/\/judykat.com\/ken-judy\/author\/ken\/#author"},"publisher":{"@id":"https:\/\/judykat.com\/ken-judy\/#person"},"image":{"@type":"ImageObject","url":"http:\/\/judykat.com\/ken-judy\/wp-content\/uploads\/public\/blogimages\/Screen-shot-2009-12-19-at-7.22.57_PM.png","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#articleImage"},"datePublished":"2009-12-19T20:16:23-05:00","dateModified":"2012-03-31T20:41:46-04:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#webpage"},"isPartOf":{"@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#webpage"},"articleSection":"software development, html, options, php, settings, themes, wordpress"},{"@type":"BreadcrumbList","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/judykat.com\/ken-judy#listItem","position":1,"name":"Home","item":"https:\/\/judykat.com\/ken-judy","nextItem":{"@type":"ListItem","@id":"https:\/\/judykat.com\/ken-judy\/category\/software-development\/#listItem","name":"software development"}},{"@type":"ListItem","@id":"https:\/\/judykat.com\/ken-judy\/category\/software-development\/#listItem","position":2,"name":"software development","item":"https:\/\/judykat.com\/ken-judy\/category\/software-development\/","nextItem":{"@type":"ListItem","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#listItem","name":"How to add an options form to a wordpress theme using settings_fields"},"previousItem":{"@type":"ListItem","@id":"https:\/\/judykat.com\/ken-judy#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#listItem","position":3,"name":"How to add an options form to a wordpress theme using settings_fields","previousItem":{"@type":"ListItem","@id":"https:\/\/judykat.com\/ken-judy\/category\/software-development\/#listItem","name":"software development"}}]},{"@type":"Person","@id":"https:\/\/judykat.com\/ken-judy\/#person","name":"Ken Judy","image":{"@type":"ImageObject","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#personImage","url":"https:\/\/secure.gravatar.com\/avatar\/0afc45b1325360e0cc414a2f6a0f1e85cd1a41dfff008d3172b91fba8fac3de8?s=96&d=mm&r=g","width":96,"height":96,"caption":"Ken Judy"},"sameAs":["kenjudy","kenjudy"]},{"@type":"Person","@id":"https:\/\/judykat.com\/ken-judy\/author\/ken\/#author","url":"https:\/\/judykat.com\/ken-judy\/author\/ken\/","name":"Ken Judy","image":{"@type":"ImageObject","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/0afc45b1325360e0cc414a2f6a0f1e85cd1a41dfff008d3172b91fba8fac3de8?s=96&d=mm&r=g","width":96,"height":96,"caption":"Ken Judy"},"sameAs":["kenjudy","kenjudy"]},{"@type":"WebPage","@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#webpage","url":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/","name":"How to add an options form to a wordpress theme using settings_fields | Ken Judy","description":"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I'd love to share one instance of the theme across these different instances. We're using enough different","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/judykat.com\/ken-judy\/#website"},"breadcrumb":{"@id":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/#breadcrumblist"},"author":{"@id":"https:\/\/judykat.com\/ken-judy\/author\/ken\/#author"},"creator":{"@id":"https:\/\/judykat.com\/ken-judy\/author\/ken\/#author"},"datePublished":"2009-12-19T20:16:23-05:00","dateModified":"2012-03-31T20:41:46-04:00"},{"@type":"WebSite","@id":"https:\/\/judykat.com\/ken-judy\/#website","url":"https:\/\/judykat.com\/ken-judy\/","name":"Ken  Judy","description":"Building AI Solutions That Work and Coaching Leaders Through Change","inLanguage":"en-US","publisher":{"@id":"https:\/\/judykat.com\/ken-judy\/#person"}}]},"og:locale":"en_US","og:site_name":"Ken  Judy | Building AI Solutions That Work and Coaching Leaders Through Change","og:type":"article","og:title":"How to add an options form to a wordpress theme using settings_fields | Ken Judy","og:description":"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I'd love to share one instance of the theme across these different instances. We're using enough different","og:url":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/","article:published_time":"2009-12-20T01:16:23+00:00","article:modified_time":"2012-04-01T00:41:46+00:00","article:author":"kenjudy","twitter:card":"summary","twitter:title":"How to add an options form to a wordpress theme using settings_fields | Ken Judy","twitter:description":"I spent some time today modifying a WordPress theme to take configuration properties. I want one theme that I can quickly re-configure to create multiple blogs along different topics with different color\/graphic schemes. I want easy maintenance so I'd love to share one instance of the theme across these different instances. We're using enough different","twitter:creator":"@kenjudy"},"aioseo_meta_data":{"post_id":"1451","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[],"defaultGraph":"","defaultPostTypeGraph":""},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":null,"created":"2020-12-21 05:35:44","updated":"2025-06-04 06:13:27","seo_analyzer_scan_date":null,"focus_keyword":null,"additional_keywords":null,"truseo_locale":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/judykat.com\/ken-judy\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/judykat.com\/ken-judy\/category\/software-development\/\" title=\"software development\">software development<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow to add an options form to a wordpress theme using settings_fields\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/judykat.com\/ken-judy"},{"label":"software development","link":"https:\/\/judykat.com\/ken-judy\/category\/software-development\/"},{"label":"How to add an options form to a wordpress theme using settings_fields","link":"https:\/\/judykat.com\/ken-judy\/how-to-add-an-options-form-to-a-wordpress-theme-using-settings_fields\/"}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/posts\/1451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/comments?post=1451"}],"version-history":[{"count":35,"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/posts\/1451\/revisions"}],"predecessor-version":[{"id":2362,"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/posts\/1451\/revisions\/2362"}],"wp:attachment":[{"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/media?parent=1451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/categories?post=1451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/judykat.com\/ken-judy\/wp-json\/wp\/v2\/tags?post=1451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}