Child Pages Listed Alphabetically
-
I’m trying to list child pages on the parent page in alphabetical order, I can get the list to show using the following code (directly in the page template) but they aren’t in order:
<? $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY 'title'", 'OBJECT'); if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); $thumbnail = get_the_post_thumbnail($pageChild->ID, 'post-thumb'); ?> <div class="child-thumb"> <a href="<?= get_permalink($pageChild->ID) ?>" rel="bookmark" title="<?= $pageChild->post_title ?>"> <?= $thumbnail ?> <?= $pageChild->post_title ?> </a> </div> <? endforeach; endif; ?>If you know of a better more efficient way please let me know. I need to show a list of children with thumbnails for the CURRENT page.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Child Pages Listed Alphabetically’ is closed to new replies.