Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sidebar to show for sub pages for each page?
#3
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.
My Github Repos: Github
Website: DigiMute
Reply


Messages In This Thread
Sidebar to show for sub pages for each page? - by n00dles101 - 2012-06-18, 08:42:52



Users browsing this thread: 1 Guest(s)