On my WordPress site, I have a structure like:
Home
page1
page2
Subject
pageA
pageB
page2B
page3B
About
Contact
where pageA, pageB, page2B and page3B all have "Subject" as their parent page.
I'm want to write a function that would detect if the term "Subject" is in the URL/page slug.
I've been trying various combinations of WordPress functions such as is_page() and get_ancestors(), but can't seem to find a way of achieving what I need.
So, the psuedo-code would be:
if (URL contains "Subject" or parent is "Subject") {
echo something
}
else {
echo something else
}