WordPress wp_list_pages将“ current_page_item”显示为第一个元素

时间:2018-09-24 10:43:55

标签: javascript php wordpress navigation

我希望包含类“ 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>

0 个答案:

没有答案