[PHP HELP] Display the child pages in a specific order?
-
You can see the page here: https://www.hotribscooljazz.org/activities/
Here is my issue… It displays the truncated content, featured image, and title for each child page, BUT the order in which it displays this content seems to be the order in which each page was created. I need to be able to control the order in which these pages is displayed, but even if I change the “published on date” in word press the order is unaffected.
What is driving the order in which these pages are being displayed? How can I edit the code below to display child pages based on the numeric value given in each pages “order” field?
<?php /** * Template Name: Activites Landing Page * Description: * * @package WordPress * @subpackage Jazz_Rib_2012 * @since Jazz and Rib Fest 2012 WordPress Theme */ get_header(); ?> <div id="pageContent"> <table class="pageContentTable"> <tr class="spacing"> </tr> <tr class="regularRow"> <td class="sidebar" valign="top" > <div class="sidebar_wrapper"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('primary-sidebar') ) : ?> <?php endif; ?> </div> </td> <td class="main_page_content" valign="top"> <div id="ContentInset"> <!---Places Page Title----> <?php if (have_posts()) : while (have_posts()) : the_post();?> <h1><?php the_title(); ?></h1> <?php endwhile; endif; ?> <!---Places Page Content----> <?php if (have_posts()) : while (have_posts()) : the_post();?> <?php the_content(); ?> <?php endwhile; endif; ?> <?php $current_page = $post->ID; $querystr = " SELECT * from $wpdb->posts WHERE post_type = 'page' AND post_parent = $current_page "; $child_pages = $wpdb->get_results($querystr, OBJECT); if ($child_pages): foreach($child_pages as $post) : setup_postdata($post); ?> <table class="activityList"> <tr> <td class="activity_logo_cell"> <a href="<?php the_permalink();?>"><?php the_post_thumbnail('Activity_Logo_Small');?></a> </td> <td class="activity_content_cell"> <h2><?php the_title(); ?></h2> <?php $thecontent = $post->post_content; $getlength = mb_strlen($thecontent); $thelength = 350; echo substr(strip_tags($thecontent), 0, $thelength); if ($getlength > $thelength) echo "…"; ?> <a href="<?php the_permalink();?>"><?php _e('[Read More]');?></a> </td> </tr> </table> <h4></h4> <?php endforeach; ?> <?php else : ?> No additional information about activities is currently available. Check back soon! <?php endif; ?> <?php rewind_posts(); ?> </div> </td> </tr> </table> </div> </div> <!---Main Content Wrapper----> <?php get_footer(); ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[PHP HELP] Display the child pages in a specific order?’ is closed to new replies.