was wondering if anyone could help me out. I have been looking all over the place for an answer and can’t seem to find one.
I am kind of a novice at PHP and i am pretty familiar with WordPress. I added three new layouts to the default twentyeleven theme. The way I envisioned this working was if someone selected a particular layout an extra sidebar would appear. So I came up with the following (yeah i know it probably isn’t correct but I did it myself and it works…lol)
$options = themeawesome_get_theme_options();
$classes = $options['three-column' || 'three-column-left' || 'three-column-right'];
if ( 'content' != $classes ) {
get_sidebar('alt');
}
like said it works great and shows the alt sidebar if any of those choices are selected in the theme options panel.
Only thing is I get the following error:
Undefined offset: 1 on line 8
line 8 being the 2nd line of code above.
Can anyone help me remove this error. Any help is greatly appreciated and thank you in advance.
You cannot use multiple indexes in an array, as you’re attempting to do with:
I’m not exactly sure what goal you’re trying to achieve, so I have multiple answers as to how to fix it.
First, declare the list of available themes:
If you want an array,
$classes, with each class, try:If you want to get the “first theme available”, try:
Because you’re following if-statement (
if ('content' != $classes)) is checking for a single string, the second of my examples may suit your needs.