Wessel Visser
Wessel Visser

Reputation: 67

How to detect if is subpage in wordpress?

I want to make a check if im on a subpage. On the homepage it is :

<?php if(is_front_page()): ?> <?php endif; ?>

But how to do it when it is another page?

Upvotes: 1

Views: 7110

Answers (1)

rnevius
rnevius

Reputation: 27092

From the docs:

There is no function to check if a page is a sub-page. We can get around the problem:

if ( is_page() && $post->post_parent > 0 ) { 
    echo "This is a child page";
}

Upvotes: 6

Related Questions