How to order posts by slug using query_posts/ Wp_query

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?

Related posts

Leave a Reply

1 comment

  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 );