stahla
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: Help to make a menu of grandchild pagesOkey so I finaly got everything to work as I wanted. Thought I share it.
My sidebar menu:
<?php /* Sidmenyn f?r alla f?rutom "grand child" */ $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 ); } /* Grand child menyn */ if( count(get_post_ancestors($post->ID)) == 2 ) { $wp_list_pages_args2 = array( 'child_of' => $post->post_parent, 'depth' => 2, 'title_li' => 0 ); wp_list_pages( $wp_list_pages_args2 ); } ?>
Container menu
<?php if($post->post_parent){ $parent = get_page($post->post_parent); if($parent->post_parent){ $wp_list_pages_args = array( 'child_of' => $parent->post_parent, 'echo' => 0, 'depth' =>1, 'title_li' => 0 ); $children = wp_list_pages($wp_list_pages_args); }else{ $wp_list_pages_args = array( 'child_of' => $post->post_parent, 'echo' => 0, 'depth' =>1, 'title_li' => 0 ); $children = wp_list_pages($wp_list_pages_args); } } else{ $wp_list_pages_args = array( 'child_of' => $post->ID, 'echo' => 0, 'depth' =>1, 'title_li' => 0 ); $children = wp_list_pages($wp_list_pages_args); } echo("<ul>"); echo $children; echo("</ul>"); ?>
Forum: Fixing WordPress
In reply to: Help to make a menu of grandchild pagesOkey 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.
Forum: Fixing WordPress
In reply to: Help to make a menu of grandchild pagesOkey I will check into that.
To explain it abit more. I have a head menu at the top of the site there its 3 options.
I refer to those as “head pages”. Each one of them have a own page template I’ve made with the code.
Then I have a second menu that should show different options depending on what “head menu option” u have pressed. So far I’ve got it all works. (Those menu options to the second menu is made out of pages with the different head menus as parents). So a second menu have all the same templates as the head menu it refers to.
Then the next thing is my sidemenu. That one should show when I’ve pressed on a menu option out of the second menu. (Those menu options to the “third/sidemenu” are made out of grandchild pages.
So a grand child page have a second menu option page as the parent.
So long I’ve come and with the code exampels before.
Forum: Fixing WordPress
In reply to: Help to make a menu of grandchild pagesHead page
-> Sub page (Parent: Head page)
-> Sub sub page (Parent: sub page)Is how I use it. And there is alot of different pages in different categories but to simplify it.