Wes*_*ser 1 php wordpress if-statement
我想检查我是否在子页面上。在首页上是:
<?php if(is_front_page()): ?> <?php endif; ?>
但是当它是另一页时该怎么办?
从字面上看,这是正确的:
没有检查页面是否为子页面的功能。我们可以解决这个问题:
if ( is_page() && $post->post_parent > 0 ) {
echo "This is a child page";
}
Run Code Online (Sandbox Code Playgroud)