Help with advanced custom page navigation.
-
Hello.
I’m trying to fix a page list system in WordPress. I have searched everywhere and tried many codes found on different places and reading the WordPress codex…
Here’s the structure that I’d like to achieve:
“Projects” is the mainpage. On this mainpage I’d like to have it’s subpages listed like:
-> Project 1
-> Project 2
-> project 3 etc…On every subpage listed above there will be more subpages related to them (let’s say we click on “Project 1”, I’d like to display these subpages):
-> Subpage 1 of project 1
-> Subpage 2 of project 1
-> Subpage 3 of project 1 etc…Now let’s say I click on “Subpage 1” this page will be displayed BUT I’d also like to display the other subpages related to “project 1”. So if I click on “Subpage 1” I’d like to display “Subpage 2” and “Subapge 3”.
I really hope you understand what I’d like to achieve here.
Here’s the code I’m working on and trying trying to fix my issue. Or maybe I’m doing it all wrong?
<ul> <li id="parent-page">Projects</li> <?php $args123 = array( 'title_li' => '', 'child_of' => $post->post_parent, 'sort_column' => post_date, 'sort_order' => desc, 'echo' => 0, 'depth' => '1' ); $args456 = array( 'title_li' => '', 'child_of' => $post->ID, 'sort_column' => post_date, 'sort_order' => desc, 'echo' => 0, 'depth' => '1' ); if($post->post_parent) $pages22 = get_pages($args123); else $pages22 = get_pages($args345); $count = 0; foreach($pages22 as $page) { $content = $page->page_parent; $content = apply_filters('the_content', $content); ?> <li id="pages"><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></li> <li class="sub-list"><?php echo get_post_meta($page->ID,'video',true); echo get_post_meta($page->ID,'text_vimeo',true); ?></li> <?php } ?> </ul>
The code above works like this now:
The mainpage “Projects” display ALL pages (even other mainpages).
Subpage “Project 1” display all other subpages (Project 2, Project 3..) and their respective subpages.
Subpage 1 of project 1 displays “correct” except that the page itself is also displayed.
How to go further from here?
Kind regards
Johan
- The topic ‘Help with advanced custom page navigation.’ is closed to new replies.