How to sort child pages on parent
-
Hi!
I have made a template for a one-page-scrolling website and i used the code found on this topic:
http://wordpress.org/support/topic/displaying-child-page-and-template-on-parent?replies=8
to display child pages (with their templates-parts)<?php global $wp_query; // is Page a parent page if ( $post->post_parent == 0 ) { // on a parent page, get child pages $pages = get_pages( 'hierarchical=0&parent=' . $post->ID ); // loop through child pages foreach ( $pages as $post ){ setup_postdata( $post ); // get the template name for the child page $template_name = get_post_meta( $post->ID, '_wp_page_template', true ); $template_name = ( 'default' == $template_name ) ? 'page.php' : $template_name; // default page template_part content-page.php $slug = 'page'; // check if the slug exists for the child page if ( locate_template( 'content-' . basename( $template_name ) , $load, $require_once ) != '' ) { $slug = pathinfo( $template_name, PATHINFO_FILENAME ); } // load the content template for the child page get_template_part( 'content', $slug ); } } ?>
The contents from the different child pages are automatically ordered alphabetically, I am now looking for a way to sort them in the order defined in the back-office (‘Order’)
here is the project i am working on:
http://bg-press.com/dev/eugenieviellard.com/Thanks for your help…
- The topic ‘How to sort child pages on parent’ is closed to new replies.