Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sidebar to show for sub pages for each page?
#7
n00dles101 Wrote:Hi and welcome to the forums...

Without having to install any plugins you could put the following function into your theme/functions.php file (create one if it doesn't exist)

Code:
function getSubMenu($page){
    $children=getChildren($page);
    foreach ($children as $subpage){
        $title=returnPageField($subpage,'menu');
        $url=returnPageField($subpage,'slug');
        echo '<li><a href="index.php?id='.$url.'">'.$title.'</a></li>';
        // or use below if you have fancy urls on
         //echo '<li><a href="/'.$url.'">'.$title.'</a></li>';
    }    
}

Then in your theme, put this in your sidebar:

Code:
<ul>
<?php getSubMenu($id); ?>
</ul>


Change $id to a specific page slug to get a specific subpages, otherwise it will create subpages for whatever page your on.

This solution works to do what i want to accomplish, however it doesn't display the title of the page until it has been re-saved. Not a clue how this can be. Have you experienced this?
Reply


Messages In This Thread
Sidebar to show for sub pages for each page? - by pierre - 2012-08-21, 22:22:05



Users browsing this thread: 1 Guest(s)