Sometimes you want to obtain a list with the URL for all of your WordPress posts. Use cases which come to mind could be when you are trying to sell your website – or buying a site – or when you want to maintain a spreadsheet for your social media calendar.

Luckily WordPress makes this very easy a thing to do. In this post, we are going to show you a simple bit of code to save as a .php file and which will allow you to export all post URLs.

Obviously, since this is WordPress… there’s a plugin for that too.

Create Your Own Export Script

To obtain a list of all the URLs of all your post you just need to make a file, using WordPress functionality. Easiest is to name the new file which we are going to create export.php.

You can create this file in your FTP-client, in your cPanel’s File Manager, or in any text/code editor you have installed on your computer and then upload the script to your website’s hosting folder.

All you need is the following script. Copy and paste the code in the new export.php you create.

foreach($posts as $post) {
    switch ($post->post_type) {
        case 'revision':
        case 'nav_menu_item':
        case 'page':
            $permalink = get_page_link($post->ID);
        case 'post':
            $permalink = get_permalink($post->ID);
        case 'attachment':
            $permalink = get_attachment_link($post->ID);
            $permalink = get_post_permalink($post->ID);
    echo "\n{$permalink}";
  //echo "\n{$post->post_type}\t{$permalink}\t{$post->post_title}";

Copy and paste the code in the new export.php you create. And save it all. If you did craft the file locally, don’t forget to upload it to your WordPress main folder via your FTP-client1.

Next, you only have to navigate to the script anymore and you will receive a list with the URLs for all your posts. To navigate to the script, visit your domain with added export.php to it.

Enter this in your browser’s address bar2:

There’s a Plugin for That

If you prefer taking an easier route, there’s [pretty much] always a plugin which can make this task even faster for you. Personally here at rockingWP we like the lightweight List URLs plugin by Graphem Solutions.

The plugin is that lightweight it even doesn’t have screenshots in it WordPress plugin page. All it does is provide you with an easy to export all URLs of ALL posts, all custom post types for examples, in a .csv file.

The List URLs plugin is a free download available from, or to be installed from within your WP-admin.

  1. Or with cPanel’s File Manager 
  2. Don’t forget to change