Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Custom Admin Options Panels WordPress

  • SOLVED

Hi There,

I need your help to create custom admin options pages for a clients website. These custom pages will make it easy for them to add certain info like google analytics tracking code, etc.

I have experience working with a custom admin options panel. I followed this tutorial and all has worked well in the past: http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/

The difference that I would like to create for this clients site, is that I want there to be multiple options pages rather than just the one page. So for example I would like there to be a new button created that says "Custom Settings", and below that will be 5 or so other options pages. (similar to how wordpress by default has a "settings" button and below that are General, Reading, Writing, etc.

I'm looking for you to please help create a "Shell" of the 1 new main page and 5 sub pages. The information on these pages can be blank, I will add the options myself. Please just indicate where I should input this information.

Also, I am looking for a small script to redirect the user to the 'parent' custom admin page after they activate the theme.

I have attached a screenshot to give you a visual idea about what I need to create.

Thank you very much for your expert help.

Cheers.

Answers (2)

2010-08-22

Monster Coder answers:

hello,
from your plugin you can create multi-page options using the following technique! i believe you already know how to make single page!

for multiple page, you need to do following!

1st, add the main menu

add_menu_page(__('Your Main Option Page'),__('Your Main Option Page'),'manage_options',__FILE__,'callback_function_1');

now add as many sub-menu as you want using the following techniques:

add_submenu_page(__FILE__,__('Sub Options Page 1'),__('Sub Options Page 1'),'manage_options','callback_function_2','callback_function_2');
add_submenu_page(__FILE__,__('Sub Options Page 2'),__('Sub Options Page 2'),'manage_options','callback_function_2','callback_function_2');


now replace callback_function_1, callback_function_2, callback_function_3 with your appropriate callback function name and inside these functions design the page as you want to see! this should be similar of making a single page that you already know!

Thanks


WP_Designer comments:

Hi,

I am slightly confused by the code you provided.

Where exactly would I add the various options for each of the pages?


Monster Coder comments:

it is same as you add single option page! ok, let me show you that!

register a function to admin_menu hook
add_action ( 'admin_menu', 'options_pages' );


now inside options_pages function you put those codes
function options_pages(){
add_menu_page(__('Your Main Option Page'),__('Your Main Option Page'),'manage_options',__FILE__,'callback_function_1');
add_submenu_page(__FILE__,__('Sub Options Page 1'),__('Sub Options Page 1'),'manage_options','callback_function_2','callback_function_2');

add_submenu_page(__FILE__,__('Sub Options Page 2'),__('Sub Options Page 2'),'manage_options','callback_function_2','callback_function_2');

}


now you have to create each callback functions you have defined!

function callback_function_1(){
echo '<div class="wrap"> <h1>Main Option Page</h2></div>';
}

function callback_function_2(){
echo '<div class="wrap"> <h1>2nd Option Page</h2></div>';
}

function callback_function_3(){
echo '<div class="wrap"> <h1>3rd Option Page</h2></div>';
}


i hope you are clear now!

2010-08-22

Nilesh shiragave answers:

Hi

You want to add different settings for each page. Or on the client site there are only 5 pages on which you want different settings for google analytics. If you have only 5 pages then you can do that using settings by creating 5 options pages.

If the client have more than 5 pages we can add analytic codes or any other options by using custom fields. And if a page / post dont have these custom fields added we can show the google analytic code added using a default theme option page which we will create in admin,using admin option page.

Nilesh


WP_Designer comments:

Hi,

When I talk about pages I am not talking about regular content pages. I am talking about custom admin pages. There will be different admin options for the user to set on each of the custom admin pages. I will fetch this information and display it where it is needed within the theme.

I am not looking to use 'custom fields'. I need custom admin pages.

Please refer to my screenshot to see what I mean about admin options pages.

Cheers.


Nilesh shiragave comments:

Ok.

Yes i saw the image you added? can you explain all the options which you want for each page as you specified in the screenshot.


WP_Designer comments:

I'm still uncertain about all of the options.

I am looking to have a "Shell" created for me, with the 1 main page and 5 sub pages. Please just indicate in the code where I should enter the options for each of the pages.

I really appreciate your help.

Cheers.