这将输出CSV导出:
将其弹出到WordPress安装根目录中的文件中(例如。export.php), 确保更改$category_ids 具有所有特定类别的ID。
<?php
require \'./wp-load.php\';
header( \'Content-Type: text/csv; charset=\' . get_bloginfo( \'charset\' ) );
header( \'Content-Disposition: attachment; filename=posts.csv\' );
$category_tax = \'category\'; // Change if different category taxonomy
$category_ids = [ 1, 2, 3, 4, 5, 6, 7, 8 ]; // The 8 specific category IDs
$query = new WP_Query;
$paged = 1;
$fopen = fopen( \'php://output\', \'w\' );
while ( true ) {
    $query->query([
        \'post_type\'      => \'post\', // Change if different post type
        \'post_status\'    => [ \'publish\', \'private\' ],
        \'posts_per_page\' => 50,
        \'no_found_rows\'  => true,
        \'paged\'          => $paged++,
        \'tax_query\'      => [[
            \'taxonomy\' => $category_tax,
            \'terms\'    => $category_ids,
        ]],
    ]);
    if ( ! $query->have_posts() )
        break;
    foreach ( $query->posts as $post ) {
        $cats = [];
        if ( $terms = get_the_terms( $post, $category_tax ) ) {
            foreach ( $terms as $term ) {
                if ( in_array( $term->term_id, $category_ids ) )
                    $cats[] = $term->term_id;
            }
        }
        fputcsv( $fopen, [
            $post->post_title,
            $post->post_name, // Slug - use get_page_uri( $post ) instead if posts are hierarchical
            $post->post_content, // Use apply_filters( \'the_content\', $post->post_content ) if you want HTML-rendered frontend output
            $post->menu_order, // Order ID
            implode( \':\', $cats ), // Colon-separated list of the category IDs (if more than one)
        ]);
    }
}