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 have 2 sidebars(primary and secondary). I want the secondary sidebar to display only on the blog page and primary sidebar to display everywhere else except for the blog page. What have I tried:

In functions.php :

if (is_page('blog-35')) {
} else {

Unfortunately this doesn't work. Any hints on how to debug this? I don't understand what am I doing wrong in the code above.(blog-35 is the body class of the page I want to display only the secondary sidebar)

share|improve this question

First: is_page() expects a page id, so the call would be is_page(35).

Second: get_sidebar needs to be called from the template (not the functions file).

You probably already have two templates setup:

  • page.php - In here you'll call get_sidebar('primary');

  • index.php (assuming your blog is on the home page) - In here you'll call get_sidebar('secondary');

Please let me know if this answers your questions!

share|improve this answer
is_page() works fine with slugs: @param mixed $page Page ID, title, slug, or array of such. – toscho Apr 27 '13 at 18:54
I was unaware of the slug usage with is_page ... turns out you can also use page title. That's why I love Stack Exchange, forever learning something new – Pizaul Apr 27 '13 at 22:55
did moving your calls from functions.php to the appropriate template file solve your problem? – Pizaul Apr 27 '13 at 22:56

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.