Hi, I need to sort pages alphabetically, here's my code <div id="all-pages"> <ul> <?php global $post; $args = array('include' => array(453,471,1248,459,458,469,457,463,465,473,475,494,477,479,481,487,489,491, 'sort_order' => 'ASC', 'sort_column' => 'post_title', )); $posts = get_pages($args); foreach($posts as $post): setup_postdata($post); ?> <li> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> <a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail($post->ID, 'full'); ?></a> </li> <?php endforeach; ?> </ul> </div> what am I missing? PHP:
Are you sorting pages or posts on a page? It looks like you are trying to list posts by alphabetical order. You would do that like this: <?php $args = array( 'numberposts' => 10, 'order'=> 'ASC', 'orderby' => 'title' ); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <div> <?php the_date(); ?> <br /> <?php the_title(); ?> <?php the_excerpt(); ?> </div> <?php endforeach; ?> PHP:
that is for posts, right? I want to list pages and only those ids 453,471,1248,459,458,469,457,463,465,473,475,494,477,479,481,487,489,491,
something like <div id="all-pages"> <ul> <?php $args = array('include' => array(453,471,1248,459,458,469,457,463,465,473,475,494,477,479,481,487,489,491, 'sort_order' => 'ASC', 'sort_column' => 'post_title', )); $mypages = get_pages($args); foreach($mypages as $page) { $content = $page->post_content; if(!$content) // Check for empty page continue; $content = apply_filters('the_content', $content); ?> <li> <h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2> <a href="<?php echo get_page_link($page->ID) ?>"><?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?></a> <div class="entry"><?php echo $content ?></div> </li> <?php } ?> </ul> </div> PHP: