Check if is parent or ancestor
-
I need help with a code implementation. I am using the below code to display a specific widget on page parent (level 1) and child pages (level 2) however I realized I also need to have the widget on a third level (grand children) pages.
To make it more clear, the code is working fine for the first two levels:
> Parent (special widget shows)
>> Child (special widget shows)
>>> Grand Child ( special widget is not showing)This is the code:
<?php if (is_page( '8' ) || '8' == $post->post_parent) { ?> Special widget <?php } else { ?> <?php } ?>
Does anyone know how to implement this code to check if the page “8” is an ancestor?
Thanks in advance.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Check if is parent or ancestor’ is closed to new replies.