0

is there a way to export all the downloadable content from wordpress?

i found this code online for the post, but i need for the downloadable content, like all my PDF, wordfiles

    <?php

include "wp-load.php";

$posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish');
$posts = $posts->posts;
/*
global $wpdb;
$posts = $wpdb->get_results("
    SELECT ID,post_type,post_title
    FROM {$wpdb->posts}
    WHERE post_status<>'auto-draft' AND post_type NOT IN ('revision','nav_menu_item')
");
*/

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

can someone help me?

rockydude
  • 83
  • 8
  • You already have the code for downloadable content: `case 'attachment':`. . . . Learn some [debugging](http://stackoverflow.com/questions/888/how-do-you-debug-php-scripts) techiques – brasofilo Oct 15 '13 at 19:35

1 Answers1

1

Wordpress stores this content in the wp-content/uploads/ directory. You can pull all your content by downloading that folder using FTP or similar.

phil-lavin
  • 1,187
  • 7
  • 19