Support » Themes and Templates » Get list of pages and some of their custom values

  • I’m trying to create a list of sub-pages within a template that uses a custom (longer and more descriptive) page title rather than using wp_list_pages().

    I have tried the following after the loop, but all I get is a list of posts, not the sub-pages I’m after:

    <?php $page_parent = $post->ID; //copy the page id ?>
    <?php $my_query = new WP_Query('post_parent='.$page_parent); ?>
    	<?php while ($my_query->have_posts())  : $my_query->the_post(); ?>
    	<a href="<?php the_permalink() ?>" rel="bookmark"><?php if (get_post_custom_values('page_title')) echo get_post_meta($post->ID, 'page_title', true); else the_title(); ?></a>
    	<?php endwhile; ?>'

    Can anyone see what I might be doing wrong? The problem appears to be with the new WP_Query.

  • The topic ‘Get list of pages and some of their custom values’ is closed to new replies.