get_sidebar
Fires before the sidebar template file is loaded.
Description
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.
Usage
- To run the hook, copy the example below.
- // run the action
- do_action( 'get_sidebar', $name );
- The following example is for adding a hook callback.
- // define the get_sidebar callback
- function action_get_sidebar( $name ) {
- // make action magic happen here...
- };
- // add the action
- add_action( 'get_sidebar', 'action_get_sidebar', 10, 1 );
- To remove a hook callback, use the example below.
- // remove the action
- remove_action( 'get_sidebar', 'action_get_sidebar', 10, 1 );
Defined (1)
The action is defined in the following location(s).
- /wp-includes/general-template.php
- do_action( 'get_sidebar', $name );