我想检查一下我是否在子页面上。在主页上是:
<?php if(is_front_page()): ?> <?php endif; ?>
但是当是另一个页面时怎么办?
来自文档:
没有检查页面是否是子页面的功能。我们可以解决这个问题:
if ( is_page() && $post->post_parent > 0 ) { echo "This is a child page"; }