faevilangel_designs Recent Posts Threads Started
87 posts
  • Has been part of the Envato Community for over 5 years
  • Sells items exclusively on Envato Market
  • Located in United Kingdom

I have never really delved into the admin control functions (building themes that add a page to the admin menu).

I have always used pre-built widgets.

I read the codex and think I have it sussed but can someone who has done these, check for me.

 // add menu
<?php add_action('admin_menu', 'mt_add_pages'); 
 add_options_page('simpl_options', 'simpl_options', 'administrator', 'simpl__options', 'simpl_options_page');

function simpl_options_page() {
<div class="wrap">
<h2>Simpl Theme Options</h2>

<form action="&lt;?php $_SERVER['PHP_SELF']; ?&gt;" method="post">

&lt;?php settings_fields( 'simpl_theme' ); ?&gt;

<label>Featured Post Category Number:</label><br />
<input name="featured_post" type="text" value="&lt;?php echo get_option('featured_post'); ?&gt;" />
<br />
<input name="action" type="hidden" value="update" />
<input name="page_options" type="hidden" value="new_option_name" />

<p class="submit">
<input class="button-primary" type="submit" value="&lt;?php _e('Save Changes') ?&gt;" />
&lt;?php $featured_post = $_POST['featured_post']; 

function register_mysettings() { 
 register_setting( 'simpl_theme', 'featured_post' );


I’m building a featured post, and the $featured_post will store the category # then, I will call that in the index.php.

the code that uses the above,
 <?php query_posts('showposts='1'&cat='.$featured_post.'')?>

Is that code ok, or have i missed something?


53 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 1+ members
  • Has sold $40,000+ on Envato Market
  • Has collected 100+ items on Envato Market
+4 more

looks alright,

you can add

add_menu_page(‘simpl_options’, ‘theme options’, ‘administrator’, ‘simpl__options’, ‘simpl_options_page’, ’’);

just below add_options_page to show a main menu button instead of the appearance>simpl_options button that isn’t as easy to find.

Will probably get messy copy and pasting all the setting fields you will have, I use a similar template to http://www.wpshout.com/create-an-advanced-options-page-in-wordpress/

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes