WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp_nav_menu - Sub-navigation based on page (3 posts)

  1. FifeAirport
    Member
    Posted 1 year ago #

    Hi,

    I'm currently building a website for the first time using WordPress. I'm very novice with PHP and do this just as a hobby. I've gotten stuck trying to work out the new wp_nav_menu.

    This is my WIP here: http://srv02.anthonylawrence.me.uk/scottD/wordpress/

    If you go onto a page, eg http://srv02.anthonylawrence.me.uk/scottD/wordpress/fife-airport/ I have added a sub navigation to the left sidebar. There are 5 of these different navigations, one for 'Fife Airport' and its children, 'For Pilots' and its children etc.

    I am currently using this script

    <h1>Sub-navigation</h1>
    <div id="sidepanel">
    	<?php
     	 	if($post->post_parent)
      		$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
    		else
      		$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
      		if ($children) { ?>
      		<ul class="subnav">
      		<?php echo $children; ?>
      		</ul>
      <?php }  ?>
    </div>

    I've searched everywhere and have been Googling for the past 2 hours for a solution to this for wp_nav_menu. I've already created my custom menus in the admin panel, just need a way for only showing the menu for that page.

    The reason I'm wanting to use wp_nav_menu instead is so I can customise the titles of the pages to be different from the link text.

    Any solutions much appreciated.

    MTIA

  2. FifeAirport
    Member
    Posted 1 year ago #

    Would seem I have not searched hard enough!

    I've found the 'Advanced Menu Widget' plug-in which works a treat after some slight tweaking. One issue I have though, anyone have any idea why on the Airfield News page (http://srv02.anthonylawrence.me.uk/scottD/wordpress/fife-airport/airfield-news/) the menu doesn't remain when you click on a story?

  3. FifeAirport
    Member
    Posted 1 year ago #

    I've managed to create a fairly complicated but entirely useful workaround compromising of widgets & sidebars - so everything is displaying the way I want it to now, thankfully!

Topic Closed

This topic has been closed to new replies.

About this Topic