Jump to content


This topic is now archived and is closed to further replies.


Wordpress Theme Options Bug

Recommended Posts

Hi guys,

I just have converted html theme into wordpres, my themes name is blue mania.

All sidebars and xtra additional sidebars are done.



So I headed to create Theme options.

On my theme at bottom, there are 3 icons, Facebook, Twitter and FLickr.

I want admin to enter their values from backend (i.e. Theme Options)



Following is a code in my functions.php




if (get_option('bluemania_theme_options')) {
   $theme_options = get_option('bluemania_theme_options');
add_option('bluemania_theme_options', array(
   'facebook_url' => 'http://www.facebook.com/pages/xyz',
   'twitter_url' => 'http://twitter.com/#!/xyz',
   'flickr_url' => 'http://www.flickr.com'

   $theme_options = get_option('bluemania_theme_options');

add_action('admin_menu', 'theme_page_add');
function theme_page_add() {
   add_submenu_page('themes.php', 'Theme Options', 'Theme Options', 8, 'themeoptions', 'theme_page_options');
function theme_page_options(){
   global $theme_options;
   $new_values = array (
   'facebook_url' => htmlentities($_POST['facebook_url'], ENT_QUOTES),
   'twitter_url' => htmlentities($_POST['twitter_url'], ENT_QUOTES),
   'flickr_url' => htmlentities($_POST['flickr_url'], ENT_QUOTES)
   update_option('bluemania_theme_options', $new_values);
   $theme_options = $new_values;
   echo '<div>';
   echo '<h2>Blue Mania Theme Options</h2>';
<form id="form1" name="form1" method="post" action="themes.php?page=themeoptions">
  <label for="facebook_url">Facebook URL :
  <input type="text" name="facebook_url" id="facebook_url" value="<?php echo $theme_options['facebook_url']; ?>"/>
    <label for="twitter_url">Twitter URL :
    <input type="text" name="twitter_url" id="twitter_url" value="<?php echo $theme_options['twitter_url']; ?>"/>
    <label for="flickr_url">Flickr URL :
    <input type="text" name="flickr_url" id="flickr_url" value="<?php echo $theme_options['flickr_url']; ?>"/>
    <input type="submit" name="submit" id="submit" value="Update Options" />
   echo '<>';



So problem starts here >>

I go to Theme Options

I enter links

I press update button.

I refresh my wordpres home page to check whether given entered vales are giving output or not.

It gives output.

I come back to admin part and again click on Theme options.

Now in those 3 text box, it should fetch data which I have already entered but it shows nothing in textbox.

I dont click on Update Button.

I just go to my wordpress home url and refresh and that previous links disappeared.



Conclusion : After entering values on keyboard and submitting, it just wipe outs entered values from database once I open theme options again.



Whats wrong in code ?

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.