Create Custom Menu in WordPress Dashboard
Complete tutorial on create custom menu in wordpress dashboard. Discover practical examples, implementation tips, and expert advice for WordPress and WooCo
Read More →
Adding a sidebar in a WordPress theme requires editing theme templates and registering a new widget area using WordPress functions. Follow the steps below:
Log in to your WordPress dashboard and navigate to Appearance > Theme Editor to access your theme files.
Decide where to insert the sidebar. Templates like single.php, page.php, or index.php are common choices depending on your layout.
Locate the desired template in the editor and find the section where the main content is rendered. This is usually inside the WordPress loop.
To create a new sidebar area, add the following code to your functions.php file:
function custom_theme_widgets_init() {
register_sidebar(array(
'name' => __('Sidebar', 'your-text-domain'),
'id' => 'sidebar-1',
'description' => __('Widgets here appear in the sidebar.', 'your-text-domain'),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
));
}
add_action('widgets_init', 'custom_theme_widgets_init');
Add this sidebar code into your selected template (e.g., single.php):
<div id="primary" class="content-area">
<main id="main" class="site-main">
<!-- Your main content -->
</main>
</div>
<aside id="secondary" class="sidebar">
<?php dynamic_sidebar('sidebar-1'); ?>
</aside>
Use custom CSS in your stylesheet or child theme to style the sidebar layout as per your theme design.
Save all changes and preview your site to check if the sidebar displays correctly. Always back up your theme before making edits. 
Search our archives or reach out to our team for solutions and expert advice.