我创建了一个用于product woocommerce的post类型。
由于某些原因,当您转到编辑屏幕时,它显示为禁用。
这是我用来生成分类法的代码:
add_action( \'init\', \'mk_restrict_product_by_tag\', 0 );
function mk_restrict_product_by_tag() {
$labels = array(
\'name\' => \'Restricted Tags\',
\'singular_name\' => \'Restricted Tag\',
\'menu_name\' => \'Restricted Tags\',
\'all_items\' => \'All Restricted Tags\',
\'parent_item\' => \'Parent Restricted Tag\',
\'parent_item_colon\' => \'Parent Restricted Tag:\',
\'new_item_name\' => \'New Restricted Tag\',
\'add_new_item\' => \'Add New Restricted Tag\',
\'edit_item\' => \'Edit Restricted Tag\',
\'update_item\' => \'Update Restricted Tag\',
\'view_item\' => \'View Restricted Tag\',
\'separate_items_with_commas\' => \'Separate Restricted Tags with commas\',
\'add_or_remove_items\' => \'Add or remove Restricted Tags\',
\'choose_from_most_used\' => \'Choose from the most used\',
\'popular_items\' => \'Popular Restricted Tags\',
\'search_items\' => \'Search Restricted Tags\',
\'not_found\' => \'Not Found\',
\'no_terms\' => \'No Restricted Tags\',
\'items_list\' => \'Restricted Tags list\',
\'items_list_navigation\' => \'Restricted Tags list navigation\'
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'public\' => false,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'show_in_nav_menus\' => false,
\'show_tagcloud\' => false,
\'rewrite\' => false,
\'show_in_quick_edit\' => true,
\'capabilities\' =>
array (
\'manage_terms\' => \'manage_categories\',
\'edit_terms\' => \'manage_categories\',
\'delete_terms\' => \'manage_categories\',
\'assign_terms\' => \'edit_posts\',
)
);
register_taxonomy( \'mk_restricted_tag\', array(\'user\',\'product\'), $args );
}
WordPress正在生成的HTML:
<div id="tagsdiv-mk_restricted_tag" class="postbox " >
<button type="button" class="handlediv button-link" aria-expanded="true"><span class="screen-reader-text">Toggle panel: Restricted Tags</span><span class="toggle-indicator" aria-hidden="true"></span></button>
<h2 class=\'hndle\'><span>Restricted Tags</span></h2>
<div class="inside">
<div class="tagsdiv" id="mk_restricted_tag">
<div class="jaxtag">
<div class="nojs-tags hide-if-js">
<label for="tax-input-mk_restricted_tag">Add or remove Restricted Tags</label>
<p><textarea name="tax_input[mk_restricted_tag]" rows="3" cols="20" class="the-tags" id="tax-input-mk_restricted_tag" disabled=\'disabled\' aria-describedby="new-tag-mk_restricted_tag-desc"></textarea></p>
</div>
</div>
<div class="tagchecklist"></div>
</div>
</div>
</div>
如您所见,文本区域已禁用。如果我将分类法转换为层次结构,则复选框将被禁用(并且我确实可以看到术语)。
知道为什么会这样吗?