Forums

[resolved] Displaying Pages & Sub-pages effectively. (4 posts)

  1. mitchrenton
    Member
    Posted 3 years ago #

    I have to seperate divs for my pages and sub-pages, one is absolutely positioned. The problem i have is if i click on a sub page the sub-pages list disappears when im on that page, only showing the parent pages. SO the only time i see in the sub-page list is when im on a parent page. Is there another way to tackle this so both my pages and sub-pages lists stay visible? Here is the code >>

    Thanks

    <div id="navigation">
      <ul>
        <?php wp_list_pages('title_li=&depth=1'); ?>
      </ul>
    </div>
    <div id="sub-nav">
      <ul>
        <?php wp_list_pages('title_li=&child_of='.$post->ID.''); ?>
      </ul>
    </div>
  2. thelastknight
    Member
    Posted 3 years ago #

    Can you provide the link to the actual page where this is happening?

  3. mitchrenton
    Member
    Posted 3 years ago #

  4. mitchrenton
    Member
    Posted 3 years ago #

    I have found a solution to my problem. thought id share it, just incase somebody else runs into a similar problem..

    <?php global $wp_query;
     				if( empty($wp_query->post->post_parent) ) {
    					$parent = $wp_query->post->ID;
    				} else {
    				$parent = $wp_query->post->post_parent;
    			} ?>
    			<?php if(wp_list_pages("title_li=&child_of=$parent&echo=0" )): ?>
    			<div id="sub-nav">
    				<ul>
    					<?php wp_list_pages("title_li=&child_of=$parent" ); ?>
    				</ul>
    			</div>
    			<?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic