16

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?

3
  • 1
    Have you read the get_sidebar() and dynamic_sidebar() Codex entries? Jan 17, 2013 at 17:03
  • 11
    This question is useful as the difference is not clear at all after reading the WP documentation twice…
    – feeela
    Sep 18, 2014 at 12:52
  • 3
    Having just read through some docs and a tutorial, I still had to view an example and do some detective work. Nothing ambiguous about the question at all. Please see my answer in a more specific and cluttered but essentially the same question: wordpress.stackexchange.com/questions/500/… Sep 10, 2015 at 18:32

1 Answer 1

20

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 ) ).

3
  • 12
    so....what's the difference?
    – user25893
    Jan 17, 2013 at 20:46
  • 3
    get_sidebar always looks for a template file. dynamic_sidebar only looks for the associated register_sidebar details and widgets configured in wp-admin
    – here
    Sep 9, 2015 at 0:27
  • 10
    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. Sep 10, 2015 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy