Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Backend-editable footer sentence Re: Backend-editable footer sentence

#54220
chazzwick
Member

Its quite a long code, but this is what i used to do the same thing for a website recently. The Client wanted a way to put news and traffic updates on their site, and have them update it in wordpress.

Add this code to functions.php:

Code:
‘The News!’,
‘theTraffic’ => ‘The Traffic!’,
);

var $options;

/* Create new control panel function and defines administration menu, and head you do not need to modify anything in this part */
function ControlPanel() {
add_action(‘admin_menu’, array(&$this, ‘add_menu’));
add_action(‘admin_head’, array(&$this, ‘admin_head’));

/* The following code simply add options. and note the word ‘mytheme’ this can be changed to your theme name actually you just need to make all of them look same. */
if (!is_array(get_option(‘mytheme’)))
add_option(‘mytheme’, $this->default_settings);
$this->options = get_option(‘mytheme’);
}

/* This adds administration menu: Under Design, it adds a theme page called Simple Control Panel and also notice how I didn’t change mytheme name */
function add_menu() {
add_theme_page(‘Control Panel’, ‘Control Panel’, 8, “mytheme”, array(&$this, ‘optionsmenu’));
}

/* Here you put your form CSS. The control panel form has a class of themeform. so Just create your stylesheet here for themeform fields, inputs, etc…I will leave this part for you as its really easy */
function admin_head() {}

function optionsmenu() {
if ($_POST[‘ss_action’] == ‘save’) {
/* This is just to update the boxes every time we update the form */

$this->options[“theNews”] = $_POST[‘cp_theNews’];
$this->options[“theTraffic”] = $_POST[‘cp_theTraffic’];

update_option(‘mytheme’, $this->options); /* Tells wordpress to update your options.. */

echo ‘

Your changes have been saved.

‘; /* Displays successful message.. like changes have been saved! */
}

/* That is all.. lets print the form to browser */
echo ‘

‘;
echo ‘

‘;
echo ‘‘;

echo ‘

‘;
/* Field for theNews */
echo ‘

‘;

/* Field for theTraffic */
echo ‘

‘;

/* The default value is Welcome to my blog! but you can always change that..just as a very simple example */

echo ‘

‘;
echo ‘

‘;

echo ‘

‘;

}

} /* Quit Control Panel Class. Very important! */
?>

Replace theNews and theTraffic whereever you see them (in your case footersentence and headersentence).

When you logon to wordpress, you should see a menu called "Control Panel" in the Appearance section. In it will be two text boxes which you can put whatever you want in.

Now, add the following to any wordpress page (index.php, footer.php etc)

Code:

i think this should work