Hi kunalnc17,
Editing parent theme wouldn’t be good way here as the changes will be overwritten by theme updates.
Basically what you would need to do is first register new sidebar in functions.php, something like this should do the trick:
register_sidebar( array(
'name' => __( 'Custom Sidebar', 'theme-slug' ),
'id' => 'custom-sidebar',
'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'theme-slug' ),
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => '</li>',
'before_title' => '<h2 class="widgettitle">',
'after_title' => '</h2>',
) );
You can find more info about it here:
https://codex.www.ads-software.com/Function_Reference/register_sidebar
Now you will need to edit the templates for your pages and posts, for example page.php and in there find where sidebar is called, it should look similar to this:
<?php get_sidebar(); ?>
That’s the part where you need to add IF condition and call different sidebar for logged out users, it would look something like this:
<?php
if ( is_user_logged_in() ) {
get_sidebar();
} else {
get_sidebar('custom-sidebar');
}
?>
Hope this helps to get you started ??
Cheers,
Predrag