• Hi there,

    I’m using get_pages to display sub page content on the parent page. It’s working fine for outputting the post title and content, but I can’t seem to figure out how to get it to output my custom fields.

    Here’s the code I’m using:

    <?php
    $mypages = get_pages('child_of=30&sort_column=post_date&sort_order=desc');
    foreach($mypages as $page)
    		{
    	$content = $page->post_content;
    	if(!$content) // Check for empty page
    	continue;
    
    	$content = apply_filters('the_content', $content);
    ?>
    <h5><a href="<?php echo get_page_link($page->ID) ?>"><span><?php echo $page->post_title ?></span></a></h5>
    <p><?php echo $content ?></p>
    
    <?php
    }
    ?>

    Any help would be gratefully received! Thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter jonathanmorgan

    (@jonathanmorgan)

    For anyone who finds this later, I couldn’t find a way to use get_pages, so used a second loop on the page with the following code:

    <?php query_posts(array('showposts' => 1, 'post_parent' => 32, 'post_type' => 'page')); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    <h5><a href="<?php echo get_page_link($page->ID) ?>"><span><?php the_title(); ?></span></a></h5>
    <p><?php the_content(); ?></p>
    <?php the_meta(); ?>
    <?php endwhile; ?>

    And now it’s working as it should.

Viewing 1 replies (of 1 total)
  • The topic ‘Using Custom Fields with get_pages’ is closed to new replies.