admin管理员组文章数量:1304901
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.
本文标签: sidebardisplay menus on all page except one
版权声明:本文标题:sidebar - display menus on all page except one? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741789844a2397595.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
! is_page( 'phnom-penh' )
– Q Studio Commented Jan 29, 2021 at 12:22