I want to create a facebook-like-box widget in wordpress:
<div class="widget-content">
<div class="fb-like-box"
data-href="<?php echo $fbpageurl; ?>"
data-width="260"
data-colorscheme="<?php if ( is_active_sidebar('sidebar-1') ) { echo "light"; } else { echo "dark"; } ?>"
data-show-faces="true"
data-header="false"
data-stream="false"
data-show-border="false"
></div>
</div>
other file:
register_sidebar( array(
// [...]
'id' => 'sidebar-1',
// [...]
) );
If I use the widget, it always return the “true” value… I don’t know why. My other sidebar names are “sidebar-2”, “sidebar-3″…
I think it’s better to use is_dynamic_sidebar(), because this Conditional Tag checks if the current sidebar has active widgets, not like is_active_sidebar() that check only the sidebar is active or not (in use).
is_active_sidebar returns true if any widget is active inside of sidebar even if sidebar isn’t shown on that page.
I can see that your trying to change color but I can’t seem to figure out how and why. Maybe some more info would help figuring the solution to your problem.
is_active_sidebar