0
我有一個導航結構是這樣的:列表子頁面,除非沒有這樣的,在這種情況下,列表兄弟頁面,在WordPress
- 首頁
- 關於
- 團隊
- 我們特派團
- 地點
- 芝加哥
- 紐約
- 洛杉磯
- 服務
- 聯繫我們
如果我在看關於頁,我想邊欄顯示:
- 團隊
- 我們的使命
如果我期待在服務頁,我想邊欄顯示:
- 首頁
- 關於
- 位置
- 服務
- 聯繫我們
這是我目前使用的代碼。我如何修改它以便按照我想要的方式工作?
<?php
global $wp_query;
if(empty($wp_query->post->post_parent)) {
$parent = $wp_query->post->ID;
} else {
$parent = $wp_query->post->post_parent;
}
$children = get_pages('child_of='.$parent);
if(count($children) > 0) {
?>
<ul>
<?php wp_list_pages ("&title_li=&child_of=$parent"); ?>
</ul>
<?php } ?>