How To: Horizontal Menu and the subpages in vertical Menu in 2.4?


Author Message
Edwin

Posted: 4/6/2010
Quote message 

Does any one know how to create the following menu with 2.4?

Horizontal: Menu Item 1 - Menu Item 2 - Menu Item 3

Vertical in Left Sidebar:

Sub Page 1 of Menu Item 1
Sub Page 2 of Menu Item 2
etc.
 
MacVink

Posted: 9/17/2010
Quote message 

Any one?

Same question here.

Jeroen
 
Abland

Posted: 9/17/2010
Quote message 

Hi, MacVink,

I did this for a shopping mall in Artisteer version 2.3 by scripting in the sidebar1.php, and then for an update to 2.4 by using a sidebar widget:

First download, install and activate PHP Code Widget:
http://wordpress.org/extend/plugins/php-code-widget/

Add the widget in WP admin to your sidebar where you want the menu to show. For demonstration purposes, let's say you have main menu items with page id's: 1, 2, and 3
with sub pages of 1: 4, 5, 6
and sub pages of 2: 7, 8, 9
and sub pages of 3: 10, 11, 12, 13

Add the following to your phpWidget:
<?php

if (is_page(array(1,4,5,6))) {
echo "<ul>";
wp_list_pages('include=4,5,6&sort_column=post_name&title_li=');
echo "</ul>";
} elseif (is_page(array(2,7,8,9))) {
echo "<ul>";
wp_list_pages('include=7,8,9&sort_column=post_name&title_li=');
echo "</ul>";
} elseif (is_page(array(3,10,11,12,13))) {
echo "<ul>";
wp_list_pages('include=10,11,12,13&sort_column=post_name&title_li=');
echo "</ul>";
} else {
}
?>

This just says if the first menu or subitems are active, the first menu subitems show, or the second, or the third.

---------------------------

If you want the vertical menu styling you'd need to use your default sidebar without widgets. Find your sidebar that has the vertical menu, then replace the following:
<ul class="art-vmenu">

<?php art_vmenu_items(); ?>
</ul>

with the following:
<?php

if (is_page(array(1,4,5,6))) {
echo "<ul class="art-vmenu">";
wp_list_pages('include=4,5,6&sort_column=post_name&title_li=');
echo "</ul>";
} elseif (is_page(array(2,7,8,9))) {
echo "<ul class="art-vmenu">";
wp_list_pages('include=7,8,9&sort_column=post_name&title_li=');
echo "</ul>";
} elseif (is_page(array(3,10,11,12,13))) {
echo "<ul class="art-vmenu">";
wp_list_pages('include=10,11,12,13&sort_column=post_name&title_li=');
echo "</ul>";
} else {
}
?>

You'll need to identify your specific page id's and replace them in the code as needed. The final "else {}" just leaves a blank menu when none of the scripted pages are active, but you can fill it with whatever you like using the same code.