17

例:

About
--- Menu 1
--- Menu 2
--- Menu 3
--- Menu 4

私が約ページにいる場合... 私はサブページを持っています。ただし、メニュー 1 に入ると、すべてのページが消えます

私が必要としているのは、常に親ページを見ることです

現在、私はこのコードを持っています

<? if (is_page()) {
    $g_page_id = $wp_query->get_queried_object_id();
    wp_list_pages("depth=4&title_li=&child_of=".$g_page_id."&sort_column=menu_order");
   }
?>

ありがとう!

解決済み

私はこれを使用し、正常に動作します!

<?php
if ( is_page() ) :
    if( $post->post_parent ) :
        $children = wp_list_pages( 'title_li=&child_of='.$post->post_parent.'&echo=0' );
    else;
        $children = wp_list_pages( 'title_li=&child_of='.$post->ID.'&echo=0' );
    endif;
    if ($children) : ?>
        <div class="title">
            <?php
            $parent_title = get_the_title( $post->post_parent );
            echo $parent_title;
            ?>
            <span></span>
        </div>
        <ul>
            <?php echo $children; ?>
        </ul>
    <?php
    endif;
endif;
?>
4

3 に答える 3