• Resolved loauy

    (@loauy)


    Dear members,

    I hope this finds you well,

    I have the following sequence of pages

    Computer (parent)
    –child– Windows
    –child– Linux
    –child– Mac
    –child– Dos
    –child– Lindows

    I want to add benefit script to my theme display all brothers pages of current page

    for example,

    if i’m on Windows page, script should display
    Windows,Linux,Mac,Dos,Lindows

    if i’m on Mac page, script should display
    Windows,Linux,Mac,Dos,Lindows

    if i’m on Dos page, script should display
    Windows,Linux,Mac,Dos,Lindows

    etc ….

    I want the code which give me what I need 🙂

    I hope that I can explain what I need

    I hope you to help me

    Loauy

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter loauy

    (@loauy)

    No any one can help me !!!!!

    What you’re looking for is a way to render a list of “sibling pages”, ie. they share the same parent..

    <?php
    $parent = 1; // Update this to the ID of the top level(parent) page
    wp_list_pages( "parent=$parent" );
    // http://codex.wordpress.org/Function_Reference/wp_list_pages
    ?>

    You’ll get a list of pages that share that parent.

    If that’s not what you’re aiming for please provide more details about where this code is being placed and whether it’s going inside the loop.. and when this list of pages should appear(on all sibling pages regardless of parent, or just this particular set)..

    Thread Starter loauy

    (@loauy)

    ^^ Thank you Mark,

    This code exactly which I need 🙂

    But my question now, how to automatically get parent page id ??

    Well that depends where you’re calling the code, inside the loop, you can use $post->ID.

    Eg.

    wp_list_pages( "parent={$post->ID}" );

    The curly braces just make it easier to read inside syntax highlighting programs, but are not required, so this will essentially work just the same…

    wp_list_pages( "parent=$post->ID" );

    Thread Starter loauy

    (@loauy)

    many thanx for your reply Mark,

    I used

    wp_list_pages( "parent=$post->ID" );

    for my code and it works correctly 🙂

    thank you very match …

    Now I can put this post’s stat as resolved ^_^

    You’re welcome.. 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘About subpages’ is closed to new replies.