如果你的帖子类型被称为“产品”,那么如果你删除注册你帖子类型的代码并激活,比如WooCommerce,插件应该能识别这些帖子。但是,您需要配置一些元字段。
根据您的评论,WooCommerce注册product
具有以下相关代码的职位类型:
if ( post_type_exists(\'product\') )
return;
do_action( \'woocommerce_register_post_type\' );
$permalinks = get_option( \'woocommerce_permalinks\' );
$product_permalink = empty( $permalinks[\'product_base\'] ) ? _x( \'product\', \'slug\', \'woocommerce\' ) : $permalinks[\'product_base\'];
register_post_type( "product",
apply_filters( \'woocommerce_register_post_type_product\',
array(
\'labels\' => array(
\'name\' => __( \'Products\', \'woocommerce\' ),
\'singular_name\' => __( \'Product\', \'woocommerce\' ),
\'menu_name\' => _x( \'Products\', \'Admin menu name\', \'woocommerce\' ),
\'add_new\' => __( \'Add Product\', \'woocommerce\' ),
\'add_new_item\' => __( \'Add New Product\', \'woocommerce\' ),
\'edit\' => __( \'Edit\', \'woocommerce\' ),
\'edit_item\' => __( \'Edit Product\', \'woocommerce\' ),
\'new_item\' => __( \'New Product\', \'woocommerce\' ),
\'view\' => __( \'View Product\', \'woocommerce\' ),
\'view_item\' => __( \'View Product\', \'woocommerce\' ),
\'search_items\' => __( \'Search Products\', \'woocommerce\' ),
\'not_found\' => __( \'No Products found\', \'woocommerce\' ),
\'not_found_in_trash\' => __( \'No Products found in trash\', \'woocommerce\' ),
\'parent\' => __( \'Parent Product\', \'woocommerce\' )
),
\'description\' => __( \'This is where you can add new products to your store.\', \'woocommerce\' ),
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'product\',
\'map_meta_cap\' => true,
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'hierarchical\' => false, // Hierarchical causes memory issues - WP loads all records!
\'rewrite\' => $product_permalink ? array( \'slug\' => untrailingslashit( $product_permalink ), \'with_front\' => false, \'feeds\' => true ) : false,
\'query_var\' => true,
\'supports\' => array( \'title\', \'editor\', \'excerpt\', \'thumbnail\', \'comments\', \'custom-fields\', \'page-attributes\' ),
\'has_archive\' => ( $shop_page_id = wc_get_page_id( \'shop\' ) ) && get_page( $shop_page_id ) ? get_page_uri( $shop_page_id ) : \'shop\',
\'show_in_nav_menus\' => true
)
)
);
您将注意到
register_post_type
可通过
woocommerce_register_post_type_product
滤器
因此,如果您想将所有后端标签更改为“服务”,可以执行以下操作:
function wpa_137268( $args ){
$args[\'labels\'] = array(
\'name\' => __( \'Services\' ),
\'singular_name\' => __( \'Service\' ),
\'menu_name\' => _x( \'Services\', \'Admin menu name\' ),
\'add_new\' => __( \'Add Service\' ),
\'add_new_item\' => __( \'Add New Service\' ),
\'edit\' => __( \'Edit\' ),
\'edit_item\' => __( \'Edit Service\' ),
\'new_item\' => __( \'New Service\' ),
\'view\' => __( \'View Service\' ),
\'view_item\' => __( \'View Service\' ),
\'search_items\' => __( \'Search Services\' ),
\'not_found\' => __( \'No Services found\' ),
\'not_found_in_trash\' => __( \'No Services found in trash\' ),
\'parent\' => __( \'Parent Service\' )
);
return $args;
}
add_filter( \'woocommerce_register_post_type_product\', \'wpa_137268\' );
你可以从那里推断出你想要改变的任何其他东西。