WordPress Importer插件导出自定义文章类型时缺少筛选选项求助
Hey there, this is a super common issue with the WordPress Importer plugin—out of the box, it only loads filter UI elements for WordPress' built-in post types (post and page). Custom post types like your mcq don't get this treatment by default, which is why you're missing those author, category, date, and status filters when exporting.
Here's how you can fix this with some custom code (no need to mess with core plugin files, which would get overwritten on updates):
Solution 1: Add Code to Your Theme's functions.php (or Use a Snippets Plugin)
Paste this code into your active theme's functions.php file, or use a plugin like Code Snippets to add it safely without editing theme files directly:
// Add filter options for the 'mcq' custom post type add_filter( 'wp_importer_export_filters', 'enable_mcq_export_filters', 10, 2 ); function enable_mcq_export_filters( $filters, $post_type ) { // Target our custom post type if ( 'mcq' === $post_type ) { $filters = array( 'author' => __( 'Author' ), 'date' => __( 'Date' ), 'status' => __( 'Post Status' ), // Uncomment and adjust below if your mcq post type uses a custom taxonomy // 'mcq_taxonomy_slug' => __( 'MCQ Category' ), ); } return $filters; } // Make sure the filters actually affect the export query add_filter( 'wp_importer_export_query_args', 'handle_mcq_export_filters', 10, 3 ); function handle_mcq_export_filters( $args, $post_type, $filters ) { if ( 'mcq' === $post_type ) { // Handle author filter if ( ! empty( $filters['author'] ) && $filters['author'] !== '-1' ) { $args['author'] = $filters['author']; } // Handle date range filters if ( ! empty( $filters['date_from'] ) ) { $args['date_query'][0]['after'] = $filters['date_from']; } if ( ! empty( $filters['date_to'] ) ) { $args['date_query'][0]['before'] = $filters['date_to']; } // Handle post status filter if ( ! empty( $filters['status'] ) && $filters['status'] !== 'all' ) { $args['post_status'] = $filters['status']; } // Uncomment below if you added a custom taxonomy filter above // if ( ! empty( $filters['mcq_taxonomy_slug'] ) && $filters['mcq_taxonomy_slug'] !== '0' ) { // $args['tax_query'][] = array( // 'taxonomy' => 'mcq_taxonomy_slug', // 'field' => 'id', // 'terms' => $filters['mcq_taxonomy_slug'], // ); // } } return $args; }
Quick Notes on the Code:
- The first filter (
wp_importer_export_filters) tells the plugin to render the filter options for yourmcqpost type. Adjust the array to add/remove filters as needed. - The second filter (
wp_importer_export_query_args) makes sure the selected filters actually modify the export query, so you only get the content you want. - If your
mcqpost type uses a custom taxonomy (like a "MCQ Category"), uncomment the relevant lines and replacemcq_taxonomy_slugwith your actual taxonomy slug.
Solution 2: Modify the Plugin Directly (Not Recommended)
You could edit the core WordPress Importer files to add your mcq post type to the supported list, but this is a bad idea—any plugin update will wipe out your changes. Only do this for quick testing, and use Solution 1 for a permanent fix.
Verify It Works
After adding the code, refresh the export page, select the mcq post type, and you should see all the familiar filter options show up, just like they do for regular posts.
内容的提问来源于stack exchange,提问作者Shah Alom

