• Hey!
    I tried searching the forums and the codex for this, but I couldn’t really find anything that helped me (I’m a bit new to WordPress and PHP and all that).

    I would like to know if there’s any easy way of telling WordPress to display the subpages of a parent page on the same page.

    The reason is that I’m doing a site for music that I make and would like to be able to have our different albums on different pages. Mostly so it’s easier to style the page with css. Like each album in separate divs and so on.
    I tried Dan Coulter’s Discography plug-in, but it was a bit too much actually.

    If there is any other way of easily splitting up a page in sections, that might of course even be better…

    cheers, anyway
    /oscar, sweden

Viewing 4 replies - 1 through 4 (of 4 total)
  • Try adding the following to your theme’s functions.php file:

    // show all children of a page
    function ShowChildren($curr_post) {
    	$output= '';
    	if($curr_post->post_parent) $children = wp_list_pages('title_li=&child_of='.$curr_post->post_parent.'&echo=0');
    	else $children = wp_list_pages('title_li=&child_of='.$curr_post->ID.'&echo=0');
    	if ($children) {
    		$output .= '<div id="showchildren"><h3>Pages in This Section</h3><ul>'."\n";
    		$output .= $children;
    		$output .= "</ul></div>\n";
    	}
    	return $output;
    }

    Then in page.php, add the following, within the Loop, where you want the sub-page list to appear:

    <?php if (function_exists('ShowChildren') && ShowChildren($post)) echo ShowChildren($post);?>

    Thread Starter fonografist

    (@fonografist)

    okay, thank you very much, it worked like you said it would…

    but the thing is that I would like to have the actual page display, not a list of pages. but still, thanks, that made me understand wordpress a bit better…

    Thread Starter fonografist

    (@fonografist)

    sorry about this, but i got to try and bump this, just the one time…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘displaying all subpages on parent page (or splitting up pages in sections)’ is closed to new replies.