Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: get_sidebar

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
117       * Fires before the sidebar template file is loaded.
118       *
119       * @since 2.2.0
120       * @since 2.8.0 The `$name` parameter was added.
121       * @since 5.5.0 The `$args` parameter was added.
122       *
123       * @param string|null $name Name of the specific sidebar file to use. Null for the default sidebar.
124       * @param array       $args Additional arguments passed to the sidebar template.
125       */
126      do_action( 'get_sidebar', $name, $args );
127
128      $templates = array();
129      $name      = (string) $name;
130      if ( '' !== $name ) {
131           $templates[] = "sidebar-{$name}.php";
132      }
133
134      $templates[] = 'sidebar.php';
135