0

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.

1 Answer 1

2

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 } ?>
Sign up to request clarification or add additional context in comments.

1 Comment

OK that was embarrassingly easy, and of course makes complete sense. Quite why I was trying to use || I'm not sure. I blame staring at the screen for too long!! What an idiot. Thanks for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.