我使用以下代码创建了一个名为imagetags的自定义分类法:
// Register Custom Taxonomy
function custom_imagetags_taxonomy() {
$labels = array(
\'name\' => _x( \'Image Tags\', \'Taxonomy General Name\', \'text_domain\' ),
\'singular_name\' => _x( \'Image Tag\', \'Taxonomy Singular Name\', \'text_domain\' ),
\'menu_name\' => __( \'Image Tags\', \'text_domain\' ),
\'all_items\' => __( \'All Image Tags\', \'text_domain\' ),
\'parent_item\' => __( \'Parent Image Tag\', \'text_domain\' ),
\'parent_item_colon\' => __( \'Parent Image Tag:\', \'text_domain\' ),
\'new_item_name\' => __( \'New Image Tag\', \'text_domain\' ),
\'add_new_item\' => __( \'Add New Image Tag\', \'text_domain\' ),
\'edit_item\' => __( \'Edit Image Tag\', \'text_domain\' ),
\'update_item\' => __( \'Update Image Tag\', \'text_domain\' ),
\'separate_items_with_commas\' => __( \'Separate Image Tags with Commas\', \'text_domain\' ),
\'search_items\' => __( \'Search Image Tags\', \'text_domain\' ),
\'add_or_remove_items\' => __( \'Add or Remove Image Tags\', \'text_domain\' ),
\'choose_from_most_used\' => __( \'Choose From Popular Image Tags\', \'text_domain\' ),
);
$rewrite = array(
\'slug\' => \'imagetags\',
\'with_front\' => true,
\'hierarchical\' => false,
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => false,
\'public\' => true,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'show_in_nav_menus\' => true,
\'show_tagcloud\' => true,
\'rewrite\' => $rewrite,
);
register_taxonomy( \'imagetags\', \'attachment\', $args );
}
// Hook into the \'init\' action
add_action( \'init\', \'custom_imagetags_taxonomy\', 0 );
现在,我正在尝试创建一个模板页面来显示符合特定imagetag的图像。
我首先将文件命名为分类法imagetags。php
我被套圈的类型所困扰。
我试过几次,但都没用。
非常感谢您的帮助。