Forums
Home / Fixing WordPress / Custom Sidebar and custom sidebar id tage help
(@samanthaclaire)
10 years, 2 months ago
Hello! I have a small issue, mostly with me not completely understanding how WordPress pulls the sidebar id’s.
<div id="sidebar"> <ul> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('custom-sidebar') ) : endif; ?> <div style="width: 2px; height:200px; background-color: #D6D6D6"></div> </ul> </div>
This is the custom sidebar I made, just following this tutorial here: http://www.tastyplacement.com/add-sidebar-wordpress
The problem with this code is that I have another sidebar, and both use the id sidebar.
Just a few side questions about sidebars: 1) When I registered this sidebar in the functions.php file, I have this code:
if ( function_exists('register_sidebar') ) { register_sidebar(array( 'name' => 'Custom Sidebar', 'id' => 'custom-sidebar', 'description' => 'Appears as the custom sidebar on the left of the page', 'before_widget' => '<div style="height: 20px"></div><li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>'
When it says ‘id’=> ‘custom-sidebar’ – what does that refer to? What is that useful for?
How can I make this sidebar have its own id apart from the already made sidebar id?
I need a separate one because the formatting will be different.
Sorry if this is confusing, and thank you for your help
Any help here?
I really just want to understand the code listed above. What things link back to and everything.
Also, what does this mean: li id=”%1$s” class=”widget %2$s”