WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am writing this code in page.php for removing the sidebar in one page

<?php if (is_page('x')) : ?>
<?php else : ?>
<?php get_sidebar(); ?>
<?php endif; ?>

... where "x" is the ID of that page.

but I am having a bit of trouble though the forum which is the page in question does not stretch across the whole page. how can I solve this problem?

share|improve this question
This would be a CSS issue, where you need to adjust the page width to accommodate the loss of sidebar. Sadly, CSS-only issues are off-topic for this site. – shea Jun 3 '13 at 11:54
Try checking if your theme has a full-width page template or similar – shea Jun 3 '13 at 11:56
there is no option of my custumpage – Nikunj Jagad Jun 3 '13 at 12:22
up vote 0 down vote accepted

If you want to specify the page ID in is_page then you should remove the single inverted commas. Please read the documentation first. is_page() see the examples section and your issue will be solved.

share|improve this answer
where i add this condition,in which page ? – Nikunj Jagad Jun 3 '13 at 11:48
you can add this condition in your page template where the statement for adding a sidebar is written – Rohit Pande Jun 3 '13 at 12:10
i am used this condition but its also not work,, <?php endif; ?><?php if (!is_page('portfolio-3')) : get_sidebar(); endif; ?> <div class="<?php if (!is_page('portfolio-3')) : ?>myclass<?php else : ?>myclasswider<?php endif; ?>"> – Nikunj Jagad Jun 3 '13 at 12:12
The code seems to be okay. Isn't this doing what is expected? – Rohit Pande Jun 3 '13 at 12:16
its remove sidebar but all content of page not display on sidebar space, – Nikunj Jagad Jun 3 '13 at 12:19

This condition is check in page.php

you have check condition 2 times on page.php

First your div like

<div class="container <?php if(is_page('x')) { echo 'new_class'}">

Here new_class is your full width class which overwrite to container class.

Same as for sidebar do this

share|improve this answer
i am used this condition but its also not work,, <?php endif; ?><?php if (!is_page('portfolio-3')) : get_sidebar(); endif; ?> <div class="<?php if (!is_page('portfolio-3')) : ?>myclass<?php else : ?>myclasswider<?php endif; ?>"> – Nikunj Jagad Jun 3 '13 at 12:20
Please Check your slug name. Its right ?? Because its working for me. I have tried this <div class="<?php if (!is_page('dashbord')) : ?>myclass<?php else : ?>myclasswider<?php endif; ?>">Hello</div> – kruti Jun 3 '13 at 13:17
this code remove the sidebar but not display all content on all space of page – Nikunj Jagad Jun 3 '13 at 13:20
You have to change in css like .myclass { width : 600px;} .myclasswider { width : 960px; } – kruti Jun 3 '13 at 13:24
i have all ready done this but not work, – Nikunj Jagad Jun 3 '13 at 15:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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