0

So I am using IDs inside the page array, and they worked fine for weeks. Now, for some reason ONE page with ID 383 still displays the form even though its ID is not mentioned in the code.

<?php if ((is_page(array(5,7,334)))) { ?>
<div id="form-area">
            <p class="class3">Text</p>
</div> <!-- form-area -->
<?php } ?>

How do I use condition "properly" so as to stop displaying the above form in 383 and other future pages?

3
  • Is there anything special about this page. How does it differ from any other page? Do you use this inside or outside the loop. What debug errors do you get? – Pieter Goosen Feb 9 '15 at 6:57
  • Nothing special about the page. Using outside the loop. So strange this is happening, but we created this page few weeks ago (so it's a fresh page and other pages were old ones). – Sid Feb 9 '15 at 9:13
  • The only idea I can come up with is that it seems there is one set of brackets too many. Try removing the first ( and the last ) – user2015 Feb 9 '15 at 9:31
0

I am really quite unsure what is causing this unexpected behavior as you said it worked and then suddently it started with this issue. You will need to turn on debugging, disable plugins and check for any custom filters etc which might be causing this.

Also, consider the possibility that Wordpress core got corrupted by something. If you suspect something like this, make a back up of your side and reinstall Wordpress.

Most probably, the best solution to your problem to make this more reliable is to make use of a custom page template for these pages that needs to show the specific form. This will save you from hardcoding or changing your theme from time to time to update specific ID's.

It is as easy as selecting this custom page template from the page selection meta box when you create a page that need this specific form to display

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.