Let me tell you that how to show menu only in wordpress page only and to hide on post?
Step 1:
write the following code in functions.php as shown in the figure below;

function register_custom_sidebars() {
// Register a sidebar for posts
register_sidebar( array(
'name' => __( 'Post Sidebar', 'textdomain' ),
'id' => 'post-sidebar',
'description' => __( 'Sidebar for posts', 'textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
// Register a sidebar for pages
register_sidebar( array(
'name' => __( 'Page Sidebar', 'textdomain' ),
'id' => 'page-sidebar',
'description' => __( 'Sidebar for pages', 'textdomain' ),
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
}
add_action( 'widgets_init', 'register_custom_sidebars' );
Step 2:
write the following code in sidebar.php as shown in the figure below;

if ( is_single() && get_post_type() == 'post' ) {
dynamic_sidebar( 'post-sidebar' );
} elseif ( is_page() ) {
dynamic_sidebar( 'page-sidebar' );
} else {
dynamic_sidebar( 'default-sidebar' );
}
Step 3:
Go to Appearance – > widgets and select the menu for “page sidebar” only.
