What is the difference with get_sidebar()
and dynamic_sidebar()
?
I was wondering which one I should use. Maybe one use widgets and the other one doesn't?
Please refer to the get_sidebar()
and dynamic_sidebar()
Codex entries.
The get_sidebar( $slug )
template tag includes the sidebar-$slug.php
template-part file.
The dynamic_sidebar( $slug )
template tag outputs the $slug
dynamic sidebar, as defined by register_sidebar( array( 'id' => $slug ) )
.
get_sidebar
always looks for a template file. dynamic_sidebar
only looks for the associated register_sidebar
details and widgets
configured in wp-admin
get_sidebar(templatename)
is for loading a sidebar-template of the name 'sidebar-templatename.php'
, which would have dynamic_sidebar(sidebarname)
in it. If you don't need the template, you can place dynamic_sidebar directly in your theme or other area. Beware, get_sidebar contains hooks that won't get called if it isn't used.
Commented
Sep 10, 2015 at 18:37
get_sidebar()
anddynamic_sidebar()
Codex entries?