orderby=name not working in get_posts
-
Using get_posts, ordering by slug is listed as an option in the documentation by calling orderby=name, but this doesn’t seem to have any affect on the loop.
Is there another way you can order pages by slug instead of title or ID? I don’t see it as an option using query_posts. Any ideas?
Here’s the code I’m using:
<?php global $post; $pageID = $post->ID; $myposts = get_posts('post_parent='.$pageID.'&numberposts=-1&post_type=page&orderby=name&order=ASC'); foreach($myposts as $post) : setup_postdata($post); ?> <div class="post column" id="post-<?php the_ID(); ?>"> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php if ( has_post_thumbnail() ) { the_post_thumbnail( 'thumbnail' ); } else { postimage( 'thumbnail' ); } ?></a> <h4 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> </div> <!-- /.post.column --> <?php endforeach; ?>
Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘orderby=name not working in get_posts’ is closed to new replies.