This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_sidebar/
Languages: English • 日本語 Русский • 中文(简体) • (Add your language)
Includes the sidebar.php template file from your current theme's directory.
If a name ($name) is specified then a specialized sidebar sidebar-{name}.php will be included. If sidebar-{name}.php does not exist, then it will fallback to loading sidebar.php.
If the theme contains no sidebar.php file then the sidebar from the default theme wp-includes/theme-compat/sidebar.php will be included.
<?php get_sidebar( $name ); ?>
Assume you have file wp-content/yourTheme/sidebar-nice-bar.php. The way you can include this sidebar in your page is:
<?php get_sidebar('nice-bar'); ?>
The following code is a simple example of a template for an "HTTP 404: Not Found" error (which you could include in your Theme as 404.php).
<?php get_header(); ?> <h2>Error 404 - Not Found</h2> <?php get_sidebar(); ?> <?php get_footer(); ?>
Two sidebars in one theme.
<?php get_header(); ?> <?php get_sidebar( 'left' ); ?> <?php get_sidebar( 'right' ); ?> <?php get_footer(); ?>
The file names for the right and left sidebars should be sidebar-right.php and sidebar-left.php respectively.
Different sidebar for different pages.
<?php if ( is_home() ) : get_sidebar( 'home' ); elseif ( is_404() ) : get_sidebar( '404' ); else : get_sidebar(); endif; ?>
The file names for the home and 404 sidebars should be sidebar-home.php and sidebar-404.php respectively.
get_sidebar() is located in wp-includes/general-template.php.
Widgets: is_active_widget(), the_widget(), register_widget(), unregister_widget(), wp_register_widget_control(), wp_unregister_widget_control(), wp_convert_widget_settings(), wp_get_widget_defaults(), wp_widget_description()