0
我正在建立這個網站,我有頁面的子頁面,當我點擊導航菜單中的父鏈接,我重定向到該頁面。然後,它會顯示該頁面上所有子頁面的鏈接,我的問題是,即使當我點擊子頁面鏈接時,我也希望導航菜單中的父頁面鏈接始終高亮顯示。所以最後,父頁面鏈接和子頁面鏈接都應該突出顯示。活躍的父母鏈接和孩子鏈接,而在子頁面wordpress
我試過了一些不同的東西,但都沒有工作,我可以循環出父母的所有子頁面,但不會使它們突出顯示。
<?php
if ($post->post_parent) :
$parent = $post->post_parent;
else :
$parent = $post->ID;
endif;
$childpages = get_pages('child_of=' . $parent . '&sort_column=menu_order');
?>
<div class="row pad60">
<ul class="category-nav column">
<?php foreach($childpages as $childpage) { ?>
<a href="<?= get_page_link($childpage->ID) ?>">
<li><div class="primary-btn"> <?= $childpage->post_title ?> </div></li>
</a>
<?php } // End foreach ?>
</ul>
</div>
這是我使用的是現在的東西,但我覺得這不是擺在首位,以正確的方式去..
謝謝!