WordPress Development Asked by Johny J on January 23, 2021
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')) {
get_sidebar('secondary');
} else {
get_sidebar('primary');
}
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)
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!
Answered by Pizaul on January 23, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP