Showing posts with label theme. Show all posts
Showing posts with label theme. Show all posts

Wednesday, November 5, 2008

How to create a WordPress theme option page

This tutorial will show you how to create a simple WordPress theme option page.

First, you will need a sample theme. Create a new folder in wp-contentthemes. Name it 'test' (or, whatever you like). Create three files in the 'test' folder: index.php, style.css and functions.php. Now, you should choose the 'test' theme as the current theme.

Second, open the functions.php file in your favourite text editor, and paste the following php code.
add_action('admin_menu', 'add_welcome_interface');
function add_welcome_interface()
/* add_theme_page( page_title, menu_title,
access_level/capability, file, [function]); */

add_theme_page('Your Theme Name', 'Your Theme Options',
'edit_themes', basename(__FILE__), 'editoptions');

function editoptions() {

<div class=“wrap">
<h2>Your Theme Name</h2>
<form action=“options.php" method=“post">

<?php wp_nonce_field('update-options'); ?>

<table class=“form-table">
<tr valign=“top">
<th scope=“row">First Option</th>
<td><input value=“<?php echo get_option('first_option'); ?>;"
<tr valign=“top">
<th scope=“row">Second Option</th>
<td><input value=<?php echo get_option('second_option'); ?>"

<input type=“hidden" value=“update" name=“action">
<input type="hidden" value="first_option,second_option"

<p class=“submit">
<input type=“submit" value=“<?php _e('Save Changes') ?>“


<?php } ?>

Finally, you can call the options that you save in index.php file, using the get_option() function.
echo get_option(‘first_option’);
echo get_option(’second_option’);

Function References:



Thursday, June 26, 2008

Best feature of Wordpress 2.6

WordPress is in its beta stage 1 of version 2.6 right now.


One of the new feature that I like is the theme previewer. With this feature, we can preview a theme live, before actually activating it.

Hence, we no more need an offline test server for testing new theme, before using it.


WordPress For Dummies