我需要帮助。我需要在两个地方重复分类法,分别是post和coupones post,这段代码位于clipper主题中。
此代码将分类存储放在优惠券中。
add_action(\'init\', \'clpr_post_type\', 0);
// remove_action(\'init\', \'create_builtin_taxonomies\', 0); // in case we want to remove all default WP taxonomies
// register all the custom taxonomies and custom post type
function clpr_post_type() {
global $wpdb, $app_abbr; //need $wpdb!!
// get the slug value for the ad custom post type & taxonomies
if(get_option($app_abbr.\'_coupon_permalink\')) $post_type_base_url = get_option($app_abbr.\'_coupon_permalink\'); else $post_type_base_url = \'coupon\';
if(get_option($app_abbr.\'_coupon_cat_tax_permalink\')) $cat_tax_base_url = get_option($app_abbr.\'_coupon_cat_tax_permalink\'); else $cat_tax_base_url = \'coupon-category\';
if(get_option($app_abbr.\'_coupon_type_tax_permalink\')) $type_tax_base_url = get_option($app_abbr.\'_coupon_type_tax_permalink\'); else $type_tax_base_url = \'coupon-type\';
if(get_option($app_abbr.\'_coupon_store_tax_permalink\')) $store_tax_base_url = get_option($app_abbr.\'_coupon_store_tax_permalink\'); else $store_tax_base_url = \'store\';
if(get_option($app_abbr.\'_coupon_tag_tax_permalink\')) $tag_tax_base_url = get_option($app_abbr.\'_coupon_tag_tax_permalink\'); else $tag_tax_base_url = \'coupon-tag\';
if(get_option($app_abbr.\'_coupon_image_tax_permalink\')) $image_tax_base_url = get_option($app_abbr.\'_coupon_image_tax_permalink\'); else $image_tax_base_url = \'coupon-image\';
register_post_type( APP_POST_TYPE,
array( \'labels\' => array(
\'name\' => __( \'Coupons\', \'appthemes\' ),
\'singular_name\' => __( \'Coupons\', \'appthemes\' ),
\'add_new\' => __( \'Add New\', \'appthemes\' ),
\'add_new_item\' => __( \'Add New Coupon\', \'appthemes\' ),
\'edit\' => __( \'Edit\', \'appthemes\' ),
\'edit_item\' => __( \'Edit Coupon\', \'appthemes\' ),
\'new_item\' => __( \'New Coupon\', \'appthemes\' ),
\'view\' => __( \'View Coupons\', \'appthemes\' ),
\'view_item\' => __( \'View Coupon\', \'appthemes\' ),
\'search_items\' => __( \'Search Coupons\', \'appthemes\' ),
\'not_found\' => __( \'No coupons found\', \'appthemes\' ),
\'not_found_in_trash\' => __( \'No coupons found in trash\', \'appthemes\' ),
\'parent\' => __( \'Parent Coupon\', \'appthemes\' ),
),
\'description\' => __( \'This is where you can create new coupon listings on your site.\', \'appthemes\' ),
\'public\' => true,
\'show_ui\' => true,
\'capability_type\' => \'post\',
\'publicly_queryable\' => true,
\'exclude_from_search\' => false,
\'menu_position\' => 8,
\'menu_icon\' => get_template_directory_uri() . \'/images/site_icon.png\',
\'hierarchical\' => false,
\'rewrite\' => array( \'slug\' => $post_type_base_url, \'with_front\' => false ), /* Slug set so that permalinks work when just showing post name */
\'query_var\' => true,
\'supports\' => array( \'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'trackbacks\', \'custom-fields\', \'comments\', \'revisions\', \'sticky\' )
)
);
// register post status for unreliable coupons
register_post_status( \'unreliable\',
array( \'label\' => __( \'Unreliable\', \'appthemes\' ),
\'public\' => true,
\'_builtin\' => true,
\'label_count\' => _n_noop( \'Unreliable <span class="count">(%s)</span>\', \'Unreliable <span class="count">(%s)</span>\', \'appthemes\' ),
\'show_in_admin_all_list\' => true,
\'show_in_admin_status_list\' => true,
\'capability_type\' => APP_POST_TYPE,
)
);
// register the newcategory taxonomy
register_taxonomy( APP_TAX_CAT,
array( APP_POST_TYPE ),
array( \'hierarchical\' => true,
\'labels\' => array(
\'name\' => __( \'Categories\', \'appthemes\'),
\'singular_name\' => __( \'Coupon Category\', \'appthemes\'),
\'search_items\' => __( \'Search Coupon Categories\', \'appthemes\'),
\'all_items\' => __( \'All Coupon Categories\', \'appthemes\'),
\'parent_item\' => __( \'Parent Coupon Category\', \'appthemes\'),
\'parent_item_colon\' => __( \'Parent Coupon Category:\', \'appthemes\'),
\'edit_item\' => __( \'Edit Coupon Category\', \'appthemes\'),
\'update_item\' => __( \'Update Coupon Category\', \'appthemes\'),
\'add_new_item\' => __( \'Add New Coupon Category\', \'appthemes\'),
\'new_item_name\' => __( \'New Coupon Category Name\', \'appthemes\')
),
\'show_ui\' => true,
\'query_var\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'rewrite\' => array( \'slug\' => $cat_tax_base_url, \'with_front\' => false, \'hierarchical\' => true ),
)
);
register_taxonomy( APP_TAX_TAG,
array( APP_POST_TYPE ),
array( \'hierarchical\' => false,
\'labels\' => array(
\'name\' => __( \'Coupon Tags\', \'appthemes\'),
\'singular_name\' => __( \'Coupon Tag\', \'appthemes\'),
\'search_items\' => __( \'Search Coupon Tags\', \'appthemes\'),
\'all_items\' => __( \'All Coupon Tags\', \'appthemes\'),
\'edit_item\' => __( \'Edit Coupon Tag\', \'appthemes\'),
\'update_item\' => __( \'Update Coupon Tag\', \'appthemes\'),
\'add_new_item\' => __( \'Add New Coupon Tag\', \'appthemes\'),
\'add_or_remove_items\' => __( \'Add or remove Coupon Tags\', \'appthemes\'),
\'separate_items_with_commas\' => __( \'Separate Coupon Tags with commas\', \'appthemes\'),
\'choose_from_most_used\' => __( \'Choose from the most common Coupon Tags\', \'appthemes\'),
\'new_item_name\' => __( \'New Coupon Tag Name\', \'appthemes\')
),
\'show_ui\' => true,
\'query_var\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'rewrite\' => array( \'slug\' => $tag_tax_base_url, \'with_front\' => false, \'hierarchical\' => true ),
)
);
register_taxonomy( APP_TAX_STORE,
array( APP_POST_TYPE ),
array( \'hierarchical\' => true,
\'labels\' => array(
\'name\' => __( \'Stores\', \'appthemes\'),
\'singular_name\' => __( \'Store\', \'appthemes\'),
\'search_items\' => __( \'Search Stores\', \'appthemes\'),
\'all_items\' => __( \'All Stores\', \'appthemes\'),
\'edit_item\' => __( \'Edit Store\', \'appthemes\'),
\'update_item\' => __( \'Update Store\', \'appthemes\'),
\'add_new_item\' => __( \'Add New Store\', \'appthemes\'),
\'add_or_remove_items\' => __( \'Add or remove Stores\', \'appthemes\'),
\'separate_items_with_commas\' => __( \'Separate Stores with commas\', \'appthemes\'),
\'choose_from_most_used\' => __( \'Choose from the most common Stores\', \'appthemes\'),
\'new_item_name\' => __( \'New Store Name\', \'appthemes\')
),
\'show_ui\' => true,
\'query_var\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'rewrite\' => array( \'slug\' => $store_tax_base_url, \'with_front\' => false, \'hierarchical\' => true ),
)
);
register_taxonomy( APP_TAX_TYPE,
array( APP_POST_TYPE ),
array( \'hierarchical\' => true,
\'labels\' => array(
\'name\' => __( \'Coupon Types\', \'appthemes\'),
\'singular_name\' => __( \'Coupon Type\', \'appthemes\'),
\'search_items\' => __( \'Search Coupon Types\', \'appthemes\'),
\'all_items\' => __( \'All Coupon Types\', \'appthemes\'),
\'parent_item\' => __( \'Parent Coupon Type\', \'appthemes\'),
\'parent_item_colon\' => __( \'Parent Coupon Type:\', \'appthemes\'),
\'edit_item\' => __( \'Edit Coupon Type\', \'appthemes\'),
\'update_item\' => __( \'Update Coupon Type\', \'appthemes\'),
\'add_new_item\' => __( \'Add New Coupon Type\', \'appthemes\'),
\'new_item_name\' => __( \'New Coupon Type Name\', \'appthemes\')
),
\'show_ui\' => true,
\'query_var\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'rewrite\' => array( \'slug\' => $type_tax_base_url, \'with_front\' => false, \'hierarchical\' => true ),
)
);
// register taxonomy for printable coupon images
register_taxonomy( APP_TAX_IMAGE,
array( \'attachment\' ),
array( \'hierarchical\' => false,
\'labels\' => array(
\'name\' => __( \'Coupon Images\', \'appthemes\'),
\'singular_name\' => __( \'Coupon Image\', \'appthemes\'),
\'search_items\' => __( \'Search Coupon Images\', \'appthemes\'),
\'all_items\' => __( \'All Coupon Images\', \'appthemes\'),
\'parent_item\' => __( \'Parent Coupon Image\', \'appthemes\'),
\'parent_item_colon\' => __( \'Parent Coupon Image:\', \'appthemes\'),
\'edit_item\' => __( \'Edit Coupon Image\', \'appthemes\'),
\'update_item\' => __( \'Update Coupon Image\', \'appthemes\'),
\'add_new_item\' => __( \'Add New Coupon Image\', \'appthemes\'),
\'new_item_name\' => __( \'New Coupon Image Name\', \'appthemes\')
),
\'public\' => false,
\'show_ui\' => false,
\'query_var\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'rewrite\' => array( \'slug\' => $image_tax_base_url, \'with_front\' => false, \'hierarchical\' => false ),
)
);
$wpdb->storesmeta = $wpdb->clpr_storesmeta;
// this needs to happen once after install script first runs
if ( get_option( $app_abbr.\'_rewrite_flush_flag\' ) == \'true\' ) {
flush_rewrite_rules();
delete_option( $app_abbr.\'_rewrite_flush_flag\' );
}
}
这是我在同一个文件中的代码。
// new code taxonomias
function clrp_taxonomy_post(){
global $wpdb, $app_abbr; //need $wpdb!!
if(get_option($app_abbr.\'_coupon_store_tax_permalink\')) $store_tax_base_url = get_option($app_abbr.\'_coupon_store_tax_permalink\'); else $store_tax_base_url = \'store\';
register_taxonomy( APP_TAX_STORE, // taxonomy stores
array( APP_POST_TYPE_POST ), // type POST
array( \'hierarchical\' => true,
\'labels\' => array(
\'name\' => __( \'Stores\', \'appthemes\'),
\'singular_name\' => __( \'Store\', \'appthemes\'),
\'search_items\' => __( \'Search Stores\', \'appthemes\'),
\'all_items\' => __( \'All Stores\', \'appthemes\'),
\'edit_item\' => __( \'Edit Store\', \'appthemes\'),
\'update_item\' => __( \'Update Store\', \'appthemes\'),
\'add_new_item\' => __( \'Add New Store\', \'appthemes\'),
\'add_or_remove_items\' => __( \'Add or remove Stores\', \'appthemes\'),
\'separate_items_with_commas\' => __( \'Separate Stores with commas\', \'appthemes\'),
\'choose_from_most_used\' => __( \'Choose from the most common Stores\', \'appthemes\'),
\'new_item_name\' => __( \'New Store Name\', \'appthemes\')
),
\'show_ui\' => true,
\'query_var\' => true,
\'update_count_callback\' => \'_update_post_term_count\',
\'rewrite\' => array( \'slug\' => $store_tax_base_url, \'with_front\' => false, \'hierarchical\' => true ),
)
);
}
add_action(\'init\', \'clrp_taxonomy_post\', 0);
最后一段代码只显示在post中,而不显示在优惠券中,我需要在post和优惠券中显示此分类法
感谢您的关注。