Multiple Sidebars
-
I am running into a “Call to undefined function” error when I try to instantiate two sidebars on my site.
the following code is my registration of both sidebars in my functions.php:
if ( function_exists(‘register_sidebar’) ) {
register_sidebar(array(
‘name’ => ‘main_sidebar’,
‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’
));
register_sidebar(array(
‘name’ => ‘home_sidebar’,
‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’,
‘after_widget’ => ‘</div>’,
‘before_title’ => ‘<h2>’,
‘after_title’ => ‘</h2>’
));I also have two corresponding PHP files with the following code (tailored to each file):
<?php if ( !function_exists(‘dynamic_sidebar’) || !dynamic_sidebar(‘main_sidebar’) ) : ?>
<?php endif; ?>Does anyone know why I am getting the fatal call to undefined function message?
Thanks,
Chris
-
I am running into a “Call to undefined function” error
please post the full error message;
what function is undefined?
This is the full error message copied from the log:
[Fri Apr 12 11:14:52 2013] [error] [client ::1] PHP Fatal error: Call to undefined function get_main_sidebar() in C:\\wamp\\www\\OnlineArizonaHomes\\wordpress\\wp-content\\themes\\ArizonaHomes\\index.php on line 3, referer: http://localhost/OnlineArizonaHomes/
get_main_sidebar()is not a default WordPress function – if you or your theme has not defined this function somewhere, you’ll get the error message;review:
Okay, easy fix. Just had to specify the specific sidebar in my call
<?php get_sidebar(‘main_sidebar’); ?>
Thank you for the help!
The topic ‘Multiple Sidebars’ is closed to new replies.