导出可下载的内容wordpress

时间:2013-10-15 17:46:51

标签: php wordpress

有没有办法从wordpress导出所有可下载的内容?

我在网上发现了这个代码,但是我需要可下载的内容,就像我的所有PDF文件一样

    <?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}";
}

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

Wordpress将此内容存储在wp-content / uploads /目录中。您可以使用FTP或类似文件下载该文件夹来提取所有内容。