Okey I’ve come with it this far now!
When I press a page (head page, no parent) then I show the childs of a that page in a middle menu as I call it. After that I show a big content div.
Works perfectly fine with what I want.
When I press one of the child pages I show the content of that child page and now I have a smaller content div and to the left of it a “submeny” containg menu options with the parents set to the “child of headpage” so its grandchildrens.
That works absolutelty fine aswell.
So far so good.
But when I press one of the “grand child pages” in my submeny to the left of the content:
Then I get the grandchildpages in my “middle menu” but the I still want to show the same as before.
And my menu to the left dissapear.
This is the following codes I have currently (and currently work on it will post a solution if I find it before anyone else):
CODE FOR THE MIDDLE MENU: (I know its not fully optimized and that thes a few if's in it that not used currently but its just because I'm working with it and trying different approaces, will be fixed when its finished)
<?
$child_of_value = ( $post->post_parent ? $post->post_parent : $post->ID );
$depth_value = ( $post->post_parent ? 1 : 1 );
$wp_list_pages_args = array(
'child_of' => $child_of_value,
'depth' => $depth_value,
'title_li' => 0
);
wp_list_pages( $wp_list_pages_args );
?>
My sidebarmenu: (To the left of the content)
<?php
$wp_list_pages_args = array(
'child_of' => $post->ID,
'depth' => 2,
'title_li' => 0
);
if ($post->ID == 14 || $post->ID == 16 || $post->ID == 9) {
} else {
wp_list_pages( $wp_list_pages_args );
}
?>
And my “template file” code with these files:
<?php if ($post->ID == 14 || $post->ID == 16 || $post->ID == 9) {?>
<div id="container-main-big">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h1><?php the_title();?></h1>
<?php the_content(); ?>
<?php endwhile;?>
<?php endif;?>
</div>
<? } else {?>
<div id="container-submenu" class="container-submenu-red">
<?php get_template_part( 'sidebar-menu'); ?>
</div>
<div id="container-main">
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h1><?php the_title();?></h1>
<?php the_content(); ?>
<?php endwhile;?>
<?php endif;?>
</div>
<div class="clear"></div>
<?}?>
SO: Everything works until you hit the “grand child page”. Then the middle-menu shows the “other and this grand child page” but infact I want it to show the childpages still out of the current head page.
And the menu to the left shows plain nothing, that one I instead want to show the grand child pages.