Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End WP | Side navigation of subpages.

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #36477
    SycoLV
    Member

    Hey guys! I started to make my first wp template and i have a small problem..
    So i have this script:

    
    $output = wp_list_pages('echo=0&depth=1&title_li=Sections' );

    if (is_page( )) {

    $page = $post->ID;

    if ($post->post_parent) {
    $page = $post->post_parent;
    }

    $children=wp_list_pages( 'echo=0&child_of=' . $page . '&title_li=' );


    if ($children) {
    $output = wp_list_pages( array(
    // Only pages that are children of the current page
    'child_of' => $post->ID,
    // Only show one level of hierarchy
    'depth' => 1,
    'title_li' => ''
    ) );
    }


    }

    echo $output;
    ?>

    It works, but i need that if the user enters in a page where there is no supages it shows the previous pages subpages.

    #96047
    TheDoc
    Member

    By previous page do you mean parent page or the page the user just came from? The former would be relatively easy, the latter would be both incredibly difficult and not useful.

    #96051
    SycoLV
    Member

    For example there is a nav..

    -Main Category
    — Subpage1
    —Subpage1.1
    —Subpage1.2
    —Subpage1.2
    –Subpage2
    —Subpage2.1
    –Subpage3
    –Subpage4

    is the user is in –subpage1 it shows the —subpage1.1 and —subpage1.2, BUT if hes in –subpage3 it shows –subpage1 -subpage2 and so on.. hope you understand my thought.

    #96055
    TheDoc
    Member

    Well, this would be sibling pages:

    wp_list_pages(array(
    'child_of' => $post->post_parent,
    'exclude' => $post->ID
    ))
    #96056
    TheDoc
    Member
    #96057
    SycoLV
    Member

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.