Reputation: 6530
My problem is: i Want to make my own Menubar that looks like this:
As you can see the buttons on the top are FIXED (these are the 6 Parents in which the Pages can get)
If you press on the green button the submenuitems appear. Now - if you press on the submenuitem the submenu should appear under the specific submenuitem. In html it's easy:
But now I need the subsubitem of the pages via php in this "format".
<div class="menuitem" id="info"> <a href="#"><img src="./information.jpg" height="120" width="*"></img></a></div>
<div id="infosub">
<div onClick="hoverSubMenu('infosub1')" class="submenu">submenuitem1</div>
<div id="infosub1" class="subsubmenu">
<div class="subsubitem">test1.1</div>
<div class="subsubitem">test1.2</div>
<div class="subsubitem">test1.3</div>
<div class="subsubitem">test1.4</div>
<div class="subsubitem">test1.5</div>
</div>
<div onClick="hoverSubMenu('infosub2')" class="submenu">submenuitem2</div>
<div id="infosub2" class="subsubmenu">
<div class="subsubitem">test2.1</div>
</div>
<div onClick="hoverSubMenu('infosub3')" class="submenu">submenuitem3</div>
<div id="infosub3" class="subsubmenu">
</div>
</div>
Anyone knows what I trying?
(getting the things opened and closed are no problems - the problem is only how can I get the subpages of a specific page and then also the subpages of THIS subpage and then getting it into this format)
I tried it myself like this:
<?php
// Set up the objects needed
$my_wp_query = new WP_Query();
$all_wp_pages = $my_wp_query->query(array('post_type' => 'page'));
// Get the page as an Object
$information = get_page_by_title('Information');
// Filter through all pages and find Information's children
$information_children = get_page_children( $information->ID, $all_wp_pages );
// echo what we get back from WP to the browser
echo '<div onClick="hoverSubMenu("infosub1")" class="submenu">' . print_r( $information_children, true ) . '</div>';
echo '<div id="infosub1" class="subsubmenu">';
echo '<div class="subsubitem">' ...
But there is the problem that it will show EVERY submenuitem and then show EVERY subsubmenuitem - not like in the html 1.submenuitem 1.1 subsubitem 1.2. subsubitem then 2. submenuitem 2.1. submenuitem...
Upvotes: 0
Views: 108
Reputation: 10061
There is details description to handle with wordpress menu. please try this link, it will help you. Change static nav menu to wordpress dynamic menu
I can give you some clues but you have to do a lot of stuff. Please check the following code which displays child page title in <ul><li><a href=""
current page:
$args = array(
'sort_order' => 'ASC',
'sort_column' => 'post_title',
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'meta_key' => '',
'meta_value' => '',
'authors' => '',
'parent' => get_the_ID(), // it takes the current page id
'exclude_tree' => '',
'number' => '',
'post_type' => 'page',
'post_status' => 'publish'
);
$pages = get_pages($args);
foreach($pages as $page){
$allPages .= '<li><a href="">'.$page->post_title.'</a></li>';
}
echo '<ul>'.$allPages.'</ul>';
It will help you to further solution.
Upvotes: 1