Fires before the sidebar template file is loaded.


do_action( 'get_sidebar', (string) $name ); 

The hook allows a specific sidebar template file to be used in place of the default sidebar template file. If your file is called sidebar-new.php, you would specify the filename in the hook as get_sidebar( new ).

Parameters (1)

0. $name (string)
Name of the specific sidebar file to use. null for the default sidebar.


To run the hook, copy the example below.
  1. // run the action 
  2. do_action( 'get_sidebar', $name ); 
The following example is for adding a hook callback.
  1. // define the get_sidebar callback 
  2. function action_get_sidebar( $name ) { 
  3. // make action magic happen here... 
  4. }; 
  6. // add the action 
  7. add_action( 'get_sidebar', 'action_get_sidebar', 10, 1 ); 
To remove a hook callback, use the example below.
  1. // remove the action 
  2. remove_action( 'get_sidebar', 'action_get_sidebar', 10, 1 ); 

Defined (1)

The action is defined in the following location(s).

  1. do_action( 'get_sidebar', $name );