• Resolved xhan

    (@xhan)


    How would I display a list of subpages of the page currently being viewed?

    I also need to be able to display an excerpt (which is in a custom field) and an image (also in a custom field)

    The code i have atm causes the theme to break.

    <?php
    	$pageid = page_id();
    	echo $pageid;
    	query_posts('post_type' => 'page', 'showposts' => '-1', 'page_id='.$pageid);
    	?>
    		<?php while (have_posts()) : the_post();
    		$categoryimageurl = get_post_custom_values('category_thumb');
    	$categoryexcerpt = get_post_custom_values('project_category_excerpt');
    	?>
    	<div class="projectsPageLeft">
    		<a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $categoryimageurl[0] ?>" alt="<?php the_title(); ?>" width="102" class="sectors" /></a>
    	</div>
    	<div class="projectsPageRight">
    		<span class="headerRed"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></span>
    		<br />
    			<?php echo $categoryexcerpt[0] ?>
    			<br />
    			<a href="<?php the_permalink(); ?>" rel="bookmark">View all <?php the_title(); ?> Projects ></a>
    		</div>
    		<div class="clear"></div>
    		<br />
    		<br />
    	<?php endwhile;?>
    	<?php
    	wp_reset_query();  // Restore global post data
    	?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter xhan

    (@xhan)

    Gah, the “Displaying Child pages of the current page in post format” would be idea if it worked!! woe.

    Thread Starter xhan

    (@xhan)

    The problem is that it doesn’t know the page id.

    global $post;
    echo $post->ID;

    returns 1 on all the pages.

    Thread Starter xhan

    (@xhan)

    ooh I can get it to display the correct page id now but the code doesn’t work!

    <?php if (have_posts()) : ?>
    
    	<?php while (have_posts()) : the_post(); ?>
    
    <?php echo $post->ID; ?>
    
    <?php
        $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
        $count = 0;
        foreach($pages as $page)
        {
            $content = $page->post_content;
            if(!$content)
                continue;
            if($count >= 2)
                break;
            $count++;
            $content = apply_filters('the_content', $content);
    
        ?>
            <h1 class="title"><a href=\"<?php the_permalink(); ?>\"><?php the_title(); ?></a></h1>
            <?php the_content(); ?>
        <?php
        }
    ?>
    
    	<?php endwhile; ?>
    
    <?php endif; ?>
    Thread Starter xhan

    (@xhan)

    This code works now ??

    <?php if (have_posts()) : ?>
    
    	<?php while (have_posts()) : the_post(); ?>
    
    <?php $pages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc&parent='.$post->ID);
    $count = 0;
    foreach($pages as $page)
    {
    	$content = $page->post_content;
    ?>
    <div class="item">
    	<h1 class="title"><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h1>
    	<?php echo $content ?>
    
    </div>
    <?php } ?>
    
    	<?php endwhile; ?>
    
    <?php endif; ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘List SubPages on top Level Page’ is closed to new replies.