Wordpress wpallimport插件此过滤器允许修改导入选项类型下拉列表中显示的选项
函数如下:我想将$custom\\u类型添加为字符串数组。
function wpai_custom_types( $custom_types ) {
// Modify the custom types to be shown on Step 1.
$custom_types = array("woocommerce orders" , " posts")
// Return the updated list.
return $custom_types;
}
add_filter( \'pmxi_custom_types\', \'wpai_custom_types\', 10, 1 );
但这行不通
最合适的回答,由SO网友:Just mas 整理而成
发布(&P);产品:
add_filter( \'pmxi_custom_types\', \'example_import_show_only_posts_and_products\', 10, 2 );
function example_import_show_only_posts_and_products ($custom_types, $type = \'\') {
global $wpdb;
$new_types = array();
foreach ($custom_types as $post_key => $post_obj) {
if ( $post_key == \'post\' || $post_key == \'product\' ) {
$new_types[$post_key] = $post_obj;
}
}
return $new_types;
}