Skip to content

Instantly share code, notes, and snippets.

@ivanteoh
Created July 5, 2020 07:13
Show Gist options
  • Save ivanteoh/08e711cb23ff37e4d5bfcbcaa5d67fde to your computer and use it in GitHub Desktop.
Save ivanteoh/08e711cb23ff37e4d5bfcbcaa5d67fde to your computer and use it in GitHub Desktop.
Split Sidebar into Two Divisions
if ( function_exists('register_sidebar') )
{
// Primary Sidebar
register_sidebar(array(
'name' => 'Primary Sidebar',
'id' => 'primary-sidebar',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '',
'after_title' => '',
));
// Secondary Sidebar
register_sidebar(array(
'name' => 'Secondary Sidebar',
'id' => 'secondary-sidebar',
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '',
'after_title' => '',
));
}
div.sidebar {
float: right;
width: 210px;
margin-left: -250px;
padding: 20px;
}
div#secondary-side {
clear: right;
}
<!-- begin sidebar -->
<div id="sidebar">
<ul>
<!-- sidebar lists -->
</ul>
</div><!-- #sidebar -->
<!-- end sidebar --></pre>
The new <code>sidebar.php</code> will look like this. We remove the sidebar id
and replace with primary-side and secondary-side ids. Both elements will have
sidebar class.
<pre lang="phtml" line="7"><!-- begin sidebar -->
<div id="primary-side" class="sidebar">
<ul>
<!-- primary lists -->
</ul>
</div><!-- #primary-side .sidebar -->
<div id="secondary-side" class="sidebar">
<ul>
<!-- secondary lists -->
</ul>
</div><!-- #secondary-side .sidebar -->
<!-- end sidebar -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment