我希望包含类“ current_page_item”的元素在呈现导航时位于顶部,是否可以在wordpress中这样做?如果是,也许您可以帮助我解决问题。
<div class="sidebar">
<?php
if ( is_page() && $post->post_parent ) {
$args = array(
'order' => 'ASC',
'post_parent' => $post->parent,
'post_status' => 'publish',
'post_type' => 'page'
);
$children = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->post_parent . '&echo=0' );
}
else {
$children = wp_list_pages( 'sort_column=menu_order&title_li=&child_of=' . $post->ID . '&echo=0' );
$args = array(
'order' => 'ASC',
'post_parent' => $post->ID,
'post_status' => 'publish',
'post_type' => 'page'
);
}
if ( $children) : ?>
<ul class="sidebar-list">
<?php echo $children; ?>
</ul>
<?php endif; ?>
</div>