Pieter Van Looy7,762 Points
Don't we have to print out our sidebar's in the sidebar template files, but putting the code get_sidebar() ?
I don't see the code to print out our sidebar's. How does WP knows which sidebar to print and where to print?
Liam ClarkeTreehouse Moderator 19,703 Points
the get_sidebar function gets the file sidebar.php by default.
If you had multiple sidebars you would name them with the prefix of sidebar and then pass in the parameter of the sidebar name.
in my project i have 2 sidebars.
one is the default and one is for the search page.
so i add 2 files.
sidebar.php sidebar-search.php // This can be called anything as long as it starts with sidebar.
<?php // in my index.php get_sidebar(); // This will just get the default sidebar
<?php // In my search.php get_sidebar( 'search' ); // now wordpress knows to look for a file that starts with sidebar and ends in search, seperated by a hyphen ( - )
Hope this helps