Posts: 50
Threads: 10
Joined: Apr 2015
2015-08-27, 17:41:54
(This post was last modified: 2015-08-27, 17:42:21 by stwneu.)
Hi all!
I'm usually calling my sidebars with something like:
PHP Code:
<?php if (get_parent(0)=='test' or return_page_slug()=='test') get_component('sidebar-test') ; ?>
Now I have a section where I have grandchildren and even grand-grand-children, which should also have the same sidebar. Since there isn't something like "get_grandparent", do you have a hint for me?
Thanks!
Posts: 13
Threads: 5
Joined: Jul 2015
Correct me if I am wrong but wouldn't/doesn't
<?php if (return_page_slug()=='page you want the side bar on' ) get_component('sidebar-name') ;?>
work - or do you have pages with the same name under different "parents"?
Posts: 50
Threads: 10
Joined: Apr 2015
That's right, but if I would do it this way, I would have to add a lot of pages, which is, why I'm looking for another way
Posts: 52
Threads: 2
Joined: May 2013
If I understand correctly, you'd like to have something like:
PHP Code:
<?php if( hasParent('test') || return_page_slug() == 'test') get_component('sidebar-test'); ?>
?
Posts: 50
Threads: 10
Joined: Apr 2015
(2015-09-02, 18:23:18)Everyone Wrote: If I understand correctly, you'd like to have something like:
PHP Code:
<?php if( hasParent('test') || return_page_slug() == 'test') get_component('sidebar-test'); ?>
?
To visualize it a little:
I would like to add a certain sidebar to all children of "Main Element 2". If we have only one sub-level (Second level), the script I posted originally works just fine. But then "Third level" does not have the same sidebar.
- Main Element 1
- MainElement 2
- Second level
- Third level
- Main Element 3
Posts: 3,491
Threads: 106
Joined: Mar 2010