WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Function to list all post slugs for every post in wp_posts table?

I assume there's an official function to generate a post slug, but maybe someone here already has the answer.

share|improve this question
up vote 3 down vote accepted

example - unordered list with post slugs:

  <?php foreach( get_posts('numberposts=-1') as $post ) { 
    echo '<li>' . $post->post_name . '</li>'; 
  } ?>


share|improve this answer
Thanks for the quick answer Michael. I'm actually moving posts out of WP so technically I'm not "in the loop". Surprisingly, I found the answer through Google Plus almost immediately after I posted the question: PJ Brunet - +Lloyd Budd I didn't see the slug in wp_posts, I'll check the_permalink() that's probably what I need. Lloyd Budd - +PJ Brunet the column is post_name. PJ Brunet - That worked. For example "select post_name from wp_posts LIMIT 500;" That's pretty much what I needed. – PJ Brunet Jul 14 '11 at 21:08
reference to database tables: codex.wordpress.org/Class_Reference/wpdb#Tables – Michael Jul 14 '11 at 21:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.