I'm not very good at this, so please bear with me. I have a Wordpress site with sections for different cites, and the different cities each have their own nav menu which shows for all of the pages in that city.
if ( is_page( 'phnom-penh' ) || in_array( '11760', $ancestors ) ) :
get_sidebar( 'city-phnom-penh' );
However, I want to remove the menu/sidebar just from one page in the Phnom Penh section so I can add a widgetized sidebar to that page instead. Is it possible to have this sidebar apply to all pages in that section except for one?
I'm not very good at this, so please bear with me. I have a Wordpress site with sections for different cites, and the different cities each have their own nav menu which shows for all of the pages in that city.
if ( is_page( 'phnom-penh' ) || in_array( '11760', $ancestors ) ) :
get_sidebar( 'city-phnom-penh' );
However, I want to remove the menu/sidebar just from one page in the Phnom Penh section so I can add a widgetized sidebar to that page instead. Is it possible to have this sidebar apply to all pages in that section except for one?
Share Improve this question asked Jan 29, 2021 at 12:07 LinaLina 112 bronze badges 2 |1 Answer
Reset to default 0As I noted in my comment, you can use the negation operator, like so:
if ( ! is_page( 'phnom-penh' ) ) {
get_sidebar( 'not-phnom-penh' );
} else {
get_sidebar( 'phnom-penh' );
}
Note the !
before the is_page
- that means NOT.
Also note that if you use more than once condition via ||
or OR
and either of the conditions returns true - the sidebar will be returned.
! is_page( 'phnom-penh' )
– Q Studio Commented Jan 29, 2021 at 12:22