/    Sign up×
Community /Pin to ProfileBookmark

wordpress theme options remain default in backend

Hi everyone. I’m trying to develop a premium WP theme and I have a problem with the custom options page that I’ve added.

I have set the settings table and it works. When I save my custom options the frontend shows them correctly, the settings page shows the default values though, and not the changed values. Here’s where the code goes through the options to pront them in the backend:

[CODE]
<?php foreach ($options as $value) {
switch ( $value[‘type’] ) {
case ‘text’:
?>
<tr valign=”top”>
<th scope=”row”><label for=”<?php echo $value[‘id’]; ?>”><?php echo __($value[‘name’],’thematic’); ?></label></th>
<td>
<input size=”30″ name=”<?php echo $value[‘id’]; ?>” id=”<?php echo $value[‘id’]; ?>” type=”<?php echo $value[‘type’]; ?>” value=”<?php if ( get_option( $value[‘id’] ) != “”) { echo get_option( $value[‘id’] ); } else { echo $value[‘std’]; } ?>” />
<?php echo __($value[‘desc’],’thematic’); ?>

</td>
</tr>
<?php
break;

case ‘textarea’:
$ta_options = $value[‘options’];
?>
<tr valign=”top”>
<th scope=”row”><label for=”<?php echo $value[$shortname.’id’]; ?>”><?php echo __($value[‘name’],’thematic’); ?></label></th>
<td><textarea name=”<?php echo $value[‘id’]; ?>” id=”<?php echo $value[ $shortname.’id’]; ?>” cols=”<?php echo $ta_options[‘cols’]; ?>” rows=”<?php echo $ta_options[‘rows’]; ?>”><?php
if( get_option($value[‘id’]) != “”) {
echo __(stripslashes(get_option($value[‘id’])),’thematic’);
}else{
echo __($value[‘std’],’thematic’);
}?></textarea><br /><?php echo __($value[‘desc’],’thematic’); ?></td>
</tr>
<?php
break;

case ‘nothing’:
$ta_options = $value[‘options’];
?>
</table>
<?php echo __($value[‘desc’],’thematic’); ?>
<table class=”form-table”>
<?php
break;

case ‘radio’:
?>
<tr valign=”top”>
<th scope=”row”><?php echo __($value[‘name’],’thematic’); ?></th>
<td>
<?php foreach ($value[‘options’] as $key=>$option) {
$radio_setting = get_option($value[‘id’]);
if($radio_setting != ”){
if ($key == get_option($value[‘id’]) ) {
$checked = “checked=”checked””;
} else {
$checked = “”;
}
}else{
if($key == $value[‘std’]){
$checked = “checked=”checked””;
}else{
$checked = “”;
}
}?>
<input type=”radio” name=”<?php echo $value[‘id’]; ?>” id=”<?php echo $value[‘id’] . $key; ?>” value=”<?php echo $key; ?>” <?php echo $checked; ?> /><label for=”<?php echo $value[‘id’] . $key; ?>”><?php echo $option; ?></label><br />
<?php } ?>
</td>
</tr>
<?php
break;

case ‘checkbox’:
?>
<tr valign=”top”>
<th scope=”row”><?php echo __($value[‘name’],’thematic’); ?></th>
<td>
<?php
if(get_option($value[‘id’])){
$checked = “checked=”checked””;
}else{
$checked = “”;
}
?>
<input type=”checkbox” name=”<?php echo $value[‘id’]; ?>” id=”<?php echo $value[‘id’]; ?>” value=”true” <?php echo $checked; ?> />
<label for=”<?php echo $value[‘id’]; ?>”><?php echo __($value[‘desc’],’thematic’); ?></label>
</td>
</tr>
<?php
break;

default:

break;
case ‘title’: ?>
<tr valign=”top”>
<th scope=”row”><h3><?php echo __($value[‘name’],’thematic’); ?></h3></th></tr> <?php
break;
}
}
?>[/CODE]

Can you help? I’m really frustrated with this. Thanks!

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @erevos spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.3,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...