• I am trying to update options in wp_options table through admin panel.

    $default_options=array(
            'fb_url'=>'',
            'tw_url'=>'',
            'gp_url'=>'',
            'layout'=>'',
            'post_banner'=>'',
            'top_banner'=>'',
             );
    
            add_option('thm_options',$default_options);
    
    function theme_settings_page(){
    
    	$url="";
    	if(isset($_POST['fb_url']))
    	{
    		$url=$_POST['fb_url'];
    
    	}
    	update_option('fb_url',$url);
    
    ?>
    <form method="post">
    
    Fb url:<br>
    <input type="text" name="fb_url"><br>
    
    <?php submit_button(); ?>
    </form>
    
    <?php
    }

    I want to update fb_url. But i am getting a new entry instead of update in wp_options table.

Viewing 1 replies (of 1 total)
  • Hello rphogat19

    Can you please try using checking below condition handle all checking of existence of options:

    if (FALSE === get_option('fb_url') && FALSE === update_option('fb_url',FALSE)) {
    add_option('fb_url',$url);}
    else{
    update_option('fb_url',$url);
    }

    Thanks

Viewing 1 replies (of 1 total)

The topic ‘Update options in option table’ is closed to new replies.