Closed marcinszpanowski closed 11 years ago
First thought... are you actually getting the options array? You can't simply reference $options['motto'] from anywhere unless the system already has the array stored to $options.
I put <?php $options = get_option('mythemename'); ?> in header.php, right after doctype.
Is it enough ?
No. There's two problems with that... one, something like that probably doesn't belong in the header. It should be early in the code, but the header is for including stylesheets and scripts, printing meta information and the like... not for setting variables. Second, defined that way, $options is a local variable. What this means is that it will not be accessible outside of the function that defined it. My recommendation is this...
global $options = get_option('mythemename');
Work like a charm!
I added this code:
global $options; $options = get_option('example');
Thank you for your support!
Any time! Glad I could help!
Hi, I'm the very beginner in php so I decided to post for a solution.
I've made a checkbox option:
array( 'id' => 'motto', 'type' => 'checkbox', 'title' => ('Motto Option', Redux_TEXT_DOMAIN), 'desc' => ('Motto option.', Redux_TEXT_DOMAIN), 'switch' => false, 'std' => '1' // 1 = checked | 0 = unchecked ),
And I have problem with implementation to index.php
I've tried:
<?php
if(isset($options['motto']) && $options['motto'] == '1') { echo "Motto appears here"; } else { echo "You don't want motto."; }
?>
In both cases (if checkbox is checked and unchecked) it gives me else echo. Anybody could help with it ? What am i doing wrong ?
Thanks in advance.