Ashfame
Member
Posted 2 years ago #
I designed a theme with the sidebar file content as
<div class="sidebar">
<ul>
<?php /* Widgetized sidebar, if you have the plugin installed. */
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Left Sidebar') ) : ?>
<li>
<div class="widgettitle">Left Sidebar</div>
<p>Add some widgets here.</p>
</li>
<?php endif; ?>
</ul>
</div>
I am using a child theme of this theme, now when I view this on local setup, the sidebar is like - http://img341.imageshack.us/img341/5055/96998855.png (works as expected) and if the same is viewed on live site, the sidebar looks like - http://img341.imageshack.us/img341/2605/40918899.png
Both the setups have no widgets at all, not even inactive widgets.
Also the code generated has this line
<div role="complementary" id="sidebar"> which means WordPress is producing it somehow and I need to figure that out.
Please help!
Looks like you're picking up the parent theme and not the child.
Ashfame
Member
Posted 2 years ago #
Why it is and that too only on the live site and not on local site? Any ideas?
Hard to say. Could you be missing a file somewhere in the child theme? Anything in your server error logs?
Ashfame
Member
Posted 2 years ago #
Child theme just contains a style.css with just import of the parent style.css and nothing else.
Selecting the parent theme as current theme on both setups show up the same issue. Different content on live as compared to local one.
Where I should be looking for logs? n why I should be? It isn't an error. Its just that some extra code is spitting out the output behind the scenes.
It's taking the sidebar contents from your default theme.
Ashfame
Member
Posted 2 years ago #
@kovshenin
Awesome!
But why do they differ on both setups and what should I do to fix it?
Ashfame
Member
Posted 2 years ago #
I see, I don't have any sidebar.php in my parent theme (all are in the form of sidebar-x.php) but what is causing the child theme to call the default theme sidebar? Child theme consists of only style.css so templates of parent theme are used and they call their respective sidebars. They why the default theme sidebar is coming over here? :/
If the theme contains no sidebar.php file then the sidebar from the default theme wp-content/themes/default/sidebar.php will be included.
http://codex.wordpress.org/Function_Reference/get_sidebar
Ashfame
Member
Posted 2 years ago #
even when we are explicitly calling some other sidebar sidebar-x.php for instance. It makes no sense to me. Had it been the case that I have a call to get_sidebar(); without any sidebar.php in theme folder, then the one from default theme being used is justified but when I am calling get_sidebar('x'); when I do have sidebar-x.php then why it is calling the sidebar.php from the default theme(when no widgets have been added)?
Moreover what could have caused the behavior to be different in local and live environment?
Perhaps get_sidebar('x') is looking for sidebar-x.php in your child theme? Could that be the case? And are you sure that you're not calling get_sidebar() anywhere else?
P.S. sidebar.php without widgets in the default theme results exactly in what you see in your screenshot.
Ashfame
Member
Posted 2 years ago #
AFAIK, get_sidebar('x'); will look for sidebar-x.php in child theme, then in parent theme. no?
I am not calling get_sidebar(); anywhere so no point of WP using the default theme's sidebar.php (I don't have sidebar.php in either my child or parent theme)
I need to fix this before I can release my theme publicly. It will give kinda out-of-control impression if the user will see all widgets after installing the theme.
AFAIK, get_sidebar('x'); will look for sidebar-x.php in child theme, then in parent theme. no?
That's the way it's supposed to work, yes.
Suggestion - rename sidebar-x.php to sidebar.php and try calling that.
Ashfame
Member
Posted 2 years ago #
That would be last choice to do that. I believe it will fix that but my scenario seems to be a little WP bug to me. I would want to name things semantically correct here.