wordpress開發(fā)主題時,會遇到父頁面調(diào)用子頁面標(biāo)題的時候,比如,在開發(fā)一個wordpress企業(yè)主題時,企業(yè)的服務(wù)項目,有并列的時候,這個時候就需要,把具體的服務(wù)項目,放到服務(wù)項目分類下。比如,培訓(xùn)服務(wù),具體的服務(wù)項目是,英語培訓(xùn)、語言培訓(xùn)、奧數(shù)培訓(xùn)等。

這里需要把服務(wù)項目作為父頁面,具體服務(wù)項目做為子頁面。在服務(wù)項目父頁面通過以下代碼,調(diào)用出子頁面的標(biāo)題,具體代碼如下:

 <?php 
 if($post->post_parent) 
 $children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->post_parent."&echo=0&depth=1"); 
 else 
 $children = wp_list_pages("sort_column=menu_order&title_li=&child_of=".$post->ID."&echo=0&depth=1"); 
 if ($children) { 
 echo '<ul class="service-list">'; 
 echo $children; 
 echo '</ul>'; 
 } ?>