Support » Plugins » Hacks » Ordering a list of child pages

  • Resolved pmgadget



    I’ve hacked together a template to loop thought the child pages of a page and display them with images and links.

    It works pretty well although it seems to ignore the ordering of the pages. I think this is to do with my dodgey coding rather than the set up of the page ordering.

    Here is the template in action

    And here is the code. Any suggestions as to where I am going wrong are much appreciated.

    Template Name: Section V2 Template
    ?><?php get_header(); ?>
    <div class="lay1">
    <div class="search_term">
    <h2 class="postitle"><?php the_title(); ?></h2>
    <div class="thn_post_wrap"><?php the_content(); ?> </div>
    <div class="single_metainfo"><?php edit_post_link(); ?></div>
    <?php $child_pages = $wpdb->get_results("SELECT *    FROM $wpdb->posts WHERE post_parent = ".$post->ID."    AND post_type = 'page' ORDER BY menu_order", 'OBJECT');    ?>
    <?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
    <?php $attr = array('title' => $pageChild->post_title, 'alt' => $pageChild->post_title,'class' => 'thn_thumbnail'); ?>
    <div class="lay1_wrap">
                       <?php if(have_posts()): ?><?php while(have_posts()): ?><?php the_post(); ?>
                    <div <?php post_class(); ?> id="post-<?php the_ID(); ?>"> 
                    <div class="post_image">
                         <!--CALL TO POST IMAGE-->
                        <?php if ( has_post_thumbnail($pageChild->ID) ) : ?>
                        <div class="imgwrap">
                            <div class="date_meta"><?php echo get_post_meta($pageChild->ID, 'banner', $single); ?></div>
                            <a href="<?php echo get_permalink($pageChild->ID); ?>"><?php echo get_the_post_thumbnail($pageChild->ID, 'medium'); ?></a></div>   
                        <?php else : ?>
                        <div class="imgwrap">
                            <div class="date_meta"></div>
                    		<a href="<?php echo get_permalink($pageChild->ID); ?>"><?php echo wp_get_attachment_image($photo[0]->ID ,'medium'); ?></a></div>                       
                        <?php endif; ?>
                    <div class="post_content">
                        <h2 class="postitle"><a href="<?php echo get_permalink($pageChild->ID); ?>" title="<?php echo $pageChild->post_title; ?>"><?php echo $pageChild->post_title; ?></a></h2>
                        <?php echo get_post_meta($pageChild->ID, 'page_excerpt', $single); ?>  
                <?php endwhile ?> 
                <?php endif ?>
    <?php endforeach; endif;?>
                <?php if (function_exists("theron_paginate")) {theron_paginate();} ?>
                <div class="hidden_nav"><?php paginate_links(); ?></div>
    <?php get_footer(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Ordering a list of child pages’ is closed to new replies.