简体   繁体   中英

Multiple conditional statement in Wordpress

I'm being driven a little mad by something in Wordpress that I simply cannot work out. I have the following, which works fine to display a sidebar if is_page() returns false.

if ( !is_page() ) { ?>
        <?php dynamic_sidebar( 'sidebar-1' ); ?></div>
<?php } ?>

The following also works fine to display the side bar if is_404() return false...

if ( !is_404() ) { ?>
        <?php dynamic_sidebar( 'sidebar-1' ); ?></div>
<?php } ?>

However if I try and combine the above into:

if ( !is_404() || !is_404() ) { ?>
        <?php dynamic_sidebar( 'sidebar-1' ); ?></div>
<?php } ?>

Then the sidebar is just displayed regardless of the type of page.

I've been staring at this a while now and fear I'm missing something obvious, so would welcome any help!

Thanks.

If you want to display the sidebar when it's NOT 404 page AND NOT a page:

if ( !is_404() && !is_page() ) { ?>
    <?php dynamic_sidebar( 'sidebar-1' ); ?></div>
<?php } ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM