How to show different sidebars for post and page? WordPress

 

Step 1:

write the following code in functions.php

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

Step 2:

write the following code in sidebar.php

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 post sidebar and page sidebar for your desired action.

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