Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress How to Build a WordPress Plugin Building a WordPress Plugin Settings Page Basic Markup for WordPress Settings Pages

Dovev Golan
Dovev Golan
425 Points

compatibilty problem with WP4.0

I have followed the videos and tried it on my own wp version 4.0 setup and the outcome is different.

The plugin 2 column layout is at the head of the admin side, on all pages.

alt text

4 Answers

Pol Martin
Pol Martin
8,200 Points

Ok, in your php part, look at where you 'require' the file containing the html code.

It should be required inside the my_plugin_options_page so the html would be added inside the options page when it was created.

You required it outside the function so it is always required without waiting for the action to trigger.

Pol Martin
Pol Martin
8,200 Points

Hi Dodev,

the problem is that the form you have created for the admin side of your own plugin appears on top of ALL admin pages. Is that right?

If so, it would be useful if you provided some code to look at. Maybe if we could see where you're including the HTML and check if you're hooking it to the 'admin_menu' action.

Dovev Golan
Dovev Golan
425 Points

Hi Pol,

Here is my plugin php code :

function myplugin_menu() {

     * Use the add_option_page function

    add_options_page('My Plugin', 
                     'My Plugin Options',

add_action('admin_menu', 'myplugin_menu');

function my_plugin_options_page() {
    if (!current_user_can('manage_options'))
        wp_die('You do not have permissions to access this page.');


require ('inc/options-page-wrapper.php');

Here is my options-page-wrapper.php file code :

<div class="wrap">

    <div id="icon-options-general" class="icon32"></div>
    <h2>My Plugin</h2>

    <div id="poststuff">

        <div id="post-body" class="metabox-holder columns-2">

            <!-- main content -->
            <div id="post-body-content">

                <div class="meta-box-sortables ui-sortable">

                    <div class="postbox">

                        <h3><span>Main Settings</span></h3>
                        <div class="inside">
                            <table class="form-table">
                                    <td><label for="wpmyplugin-apikey">API Id Key :</label></td>
                                    <td><input name="" id="" type="text" value="" class="regular-text" /></td>
                        </div> <!-- .inside -->

                    </div> <!-- .postbox -->

                </div> <!-- .meta-box-sortables .ui-sortable -->

            </div> <!-- post-body-content -->

            <!-- sidebar -->
            <div id="postbox-container-1" class="postbox-container">

                <div class="meta-box-sortables">

                    <div class="postbox">

                        <h3><span>Sidebar Content Header</span></h3>
                        <div class="inside">
                            Content space
                        </div> <!-- .inside -->

                    </div> <!-- .postbox -->

                </div> <!-- .meta-box-sortables -->

            </div> <!-- #postbox-container-1 .postbox-container -->

        </div> <!-- #post-body .metabox-holder .columns-2 -->

        <br class="clear">
    </div> <!-- #poststuff -->

</div> <!-- .wrap -->