I created an options page and it is functioning perfectly, but I am not sure I understand how it functions. It's cool I got it to work but I was hoping someone could help explain why it works.

Here is the code:


    add_action('admin_menu', 'add_custom_options');  

        function add_custom_options()
            add_options_page('Custom Options', 'Slider Settings', 'manage_options', 'functions','custom_options');

    function custom_options()
<div class="wrap">
    <h2>Custom Options</h2>
    <form method="post" action="options.php">
    <?php wp_nonce_field('update-options') ?>

    <input type="text" name="options_value" size="85" value="<?php echo get_option('options_value'); ?>" /> 

    <p><input type="submit" name="Submit" value="Store Options" /></p>
    <input type="hidden" name="action" value="update" />
    <input type="hidden" name="page_options" value="options_value" />


Where are these values being stored? There's a reference to options.php but my theme doesn't have an options.php. I am just trying to wrap my head around what I made to try and better understand it's logic; I am also curious if I went about it the right way. The option(s) I store are retrieved within the theme (image url for example).

Thanks in advance.

  • Maybe you can read this. It's quite common to create a particular file with custom functions that will set options and option page and then you can implement them in your theme to make it easily cutomizable though admin panel. – JMau Jun 24 '13 at 20:35
  • 1
    I know how to make the options page, I was curious how it worked, thanks anyway! – Jacob Jun 25 '13 at 5:18

The options.php in question is WordPress's /wp-admin/options.php file. Your code's hidden action & page_options fields tell options.php what to do (update) and with what (options_value).


Trac page for options.php

| improve this answer | |
  • Thanks for the answers, makes more sense now. Many Thanks! – Jacob Jun 25 '13 at 5:19
  • Glad I could help. – Pat J Jun 25 '13 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.