我一直在努力Conditional Tags 而且我也不知道这个问题。这里是PHP新手。
在子页面上,我需要显示父页面标题以及页面标题。我已将其用于:
<h1><?php echo get_the_title($post->post_parent);?></h1>
<h2><?php the_title(); ?></h2>
但我现在的问题是,在父页面上,页面标题显示两次,即父页面标题和页面标题。相反,在父页面上,我需要h2
要显示“选择子页”,如果有子页。。。如果没有子页面,则不显示任何内容。我认为这是可能的:<h1><?php echo get_the_title($post->post_parent);?></h1>
<h2>
<?php
if is_parent_page_without_children() {echo \'\';} ;
elseif is_parent_page_with_children() {echo \'select a sub-page\';} ;
else the_title();
?>
</h2>