我目前正在寻找使用用户可编辑的slug在wordpress中创建自定义帖子类型的最佳解决方案。自定义帖子类型在插件中注册,例如:
$labels = array(
'name' => _x( 'Team', 'post type general name', 'text-domain' ),
'singular_name' => _x( 'Team Member', 'post type singular name', 'text-domain' ),
'menu_name' => _x( 'Team', 'admin menu', 'text-domain' ),
'name_admin_bar' => _x( 'Team', 'add new on admin bar', 'text-domain' ),
'add_new' => _x( 'Add New', 'Property', 'text-domain' ),
'add_new_item' => __( 'Add New Team Member', 'text-domain' ),
'new_item' => __( 'New Team Member', 'text-domain' ),
'edit_item' => __( 'Edit Team Member', 'text-domain' ),
'view_item' => __( 'View Team Member', 'text-domain' ),
'all_items' => __( 'All Team Members', 'text-domain' ),
'search_items' => __( 'Search Team Member', 'text-domain' ),
'parent_item_colon' => __( 'Parent Team Member:', 'text-domain' ),
'not_found' => __( 'No team members found.', 'text-domain' ),
'not_found_in_trash' => __( 'No team members found in Trash.', 'text-domain' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Custom Post Type for your Team Members.', 'text-domain' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'team' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array(
'title',
'editor',
'author',
'thumbnail',
'excerpt'
)
);
在这个例子中,slugs名称是" team"它是硬编码的。什么是最好的解决方案,让插件用户可以将这个slug更改为自定义的。也许像WooCommerce这样的类似解决方案提供了"设置>下的产品类别基础的设置。固定链接&#34 ;.