Wordpress php: Way to test if pages are children of a parent page?
- by Erykan
Hi - Working on my first Wordpress site so I'm sure this is a really basic question. I'm struggling to write a conditional php statement that performs a certain action when a page is a child of a parent page.
For example, rather than just specifying one page, as below, I'd like to specify all pages that have the 'About Us' page as a parent:
<?php if (is_page('About Us')) echo 'Hello World!'; ?>
I've tried the "child_of" function but it wasn't as straightforward as I'd hoped.
When I use the below, I get a syntax error - probably just me not knowing how to use the function:
<?php if (child_of('About Us')) echo 'Hello World!'; ?>
Any suggestions? Thanks!!