How to show menu only in wordpress page? WordPress

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;

different sidebars for wp post and page
different sidebars for wp post and page

Step 2:

write the following code in sidebar.php as shown in the figure below;

how to show different sidebars for post and page
how to show different sidebars for post and page

 

Step 3:

Go to Appearance – > widgets and select the menu for “page sidebar” only.

show categories only in wp post but not on page
show categories only in wp post but not on page