Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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:

 <?php

    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" />

    </form>
</div>
<?php
}
?>

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.

share|improve this question
    
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
    
I know how to make the options page, I was curious how it worked, thanks anyway! –  Jacob Jun 25 '13 at 5:18
add comment

1 Answer

up vote 3 down vote accepted

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).

Reference

Trac page for options.php

share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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