我想知道如何设置一个条件语句来检查是否显示了父、子或孙。到目前为止,我得到的是:
<?php
if ( is_page( \'about\' ) || \'29\' == $post->post_parent ) {
//Start of the custom code...
while(has_sub_field(\'site_slideshows\',\'option\')):
?> <!-- Closing the PHP tag -->
<div class="slideshow-slide" style="background-image:url(<?php the_sub_field(\'site_slideshows_slide_image\'); ?>)">
<div class="block-text" style="color: <?php the_sub_field(\'site_slideshows_slide_text_colour\'); ?>;"><?php the_sub_field(\'site_slideshows_slide_text\'); ?></div>
</div>
<?php //Opening the PHP tag again
endwhile;
} elseif ( is_page( \'contact\' ) || \'31\' == $post->post_parent ) {
//Start of the custom code...
while(has_sub_field(\'two_site_slideshows\',\'option\')):
?> <!-- Closing the PHP tag -->
<div class="slideshow-slide" style="background-image:url(<?php the_sub_field(\'two_site_slideshows_slide_image\'); ?>)">
<div class="block-text" style="color: <?php the_sub_field(\'two_site_slide_text_colour\'); ?>;"><?php the_sub_field(\'two_site_slideshows_slide_text\'); ?></div>
</div>
<?php //Opening the PHP tag again
endwhile;
}
?>
这将成功检查父页面和子页面,例如
about
page和
about
页面,但我如何调整这些语句以同时包含孙子页面?如有任何建议,将不胜感激。