• webnik

    (@noisedude)


    I’m using the Mystique theme. In the Constructor theme I’ve noticed there is a page template called ‘parent’ that when chosen inserts a list of all its child pages.

    I need to find a way to put this option into Mystique. It’s part of the navigation – if they click on any part of the dropdown/flyout menu, it should load a page that lists the next step of the menu/page hierarchy.

    Ideally it would be a page template that I could choose for these currently empty holding pages.

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    Well the, as page.php in the WordPress Default theme wp-content/themes/default folder works like that:

    <?php
    /**
     * @package WordPress
     * @subpackage Default_Theme
     */
    
    get_header(); ?>
    
    	<div id="content" class="narrowcolumn" role="main">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    <?php
    //now display the child pages for this page -- also display custom field cf1
    $parent_id = $posts[0]->ID;
    $args=array(
      'post_parent' => $parent_id,
      'post_type' => 'page',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
        $meta = get_post_meta($post->ID, 'cf1', true);
        if ($meta){
          echo 'customfield1: '. $meta;
        }
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    
    	<?php comments_template(); ?>
    
    	</div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    Thread Starter webnik

    (@noisedude)

    Thanks for that, not really sure how to use it. I guess what I want to do is make a copy of my default page template and add in the code that displays a list of the child pages.

    Here’s the parent page template code from the Constructor theme – how do I pick out just the bits I need to put into my Mystique page?

    I want every other aspect of the page to look the same as my default Mystique pages.

    <?php
    /*
    Template Name: Parent Page
    */
    /**
     * @package WordPress
     * @subpackage Constructor
     */
    
    get_header(); ?>
    <div id="wrapper" class="box shadow opacity">
        <div id="container" class="container-sitemap">
            <div id="posts">
            <?php while (have_posts()) : the_post(); ?>
                <div <?php post_class(); ?> id="post-<?php the_ID() ?>">
                    <div class="title opacity box">
                        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'constructor'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
                    </div>
                    <div class="entry">
                        <?php the_content(__('Read the rest of this entry &raquo;', 'constructor')) ?>
                        <ul>
                            <?php wp_list_pages('title_li=&child_of='.$post->ID); ?>
                        </ul>
                        <?php wp_link_pages(array('before' => '<p class="pages"><strong>'.__('Pages', 'constructor').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
                    </div>
                    <div class="footer">
                        <div class="links right">
                        <?php if($post->post_parent) : $parent_link = get_permalink($post->post_parent); ?>
                        <a href="<?php echo $parent_link; ?>"><?php _e('Back to Parent Page', 'constructor');?></a> |
                        <?php endif; ?>
                        <?php the_date() ?> |
                        <?php the_tags(__('Tags', 'constructor') . ': ', ', ', '|'); ?>
                        <?php edit_post_link(__('Edit', 'constructor'), '', ' | '); ?>
                        <?php comments_popup_link(__('No Comments »', 'constructor'), __('1 Comment »', 'constructor'), __('% Comments »', 'constructor'), '', __('Comments Closed', 'constructor') ); ?>                    </div>
                        <div class="line clear"></div>
                    </div>
                </div>
            <?php endwhile; ?>
            </div>
    
        </div><!-- id='container' -->
        <?php get_constructor_sidebar(); ?>
    </div><!-- id='wrapper' -->
    <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need a page template that lists child pages’ is closed to new replies.