I want to display posts sorted by slug on a page. Is it possible to order posts by slug using query_posts or Wp_query?

1 Answer
1

In WordPress the post slug is saved in database with name post_name, so to sort posts by slug just use: orderby=name.

Edit:

Here’s the example of query:

$args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'posts_per_page' => 10,
    'orderby' => 'name'
);
$query = new WP_Query( $args );

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *