全国服务热线:4008-888-888

技术知识

wordpress建立好几个自定文章内容种类的方式

涵数编码:
// register post type label args function tj_cutom_post_type_label_args($typeName){ return $labels = array( 'name' = $typeName, 'singular_name' = $typeName, 'add_new' = 'Add New', 'add_new_item' = 'Add New '.$typeName, 'edit_item' = 'Edit '.$typeName, 'new_item' = 'New '.$typeName, 'all_items' = 'All '.$typeName, 'view_item' = 'View '.$typeName, 'search_items' = 'Search '.$typeName, 'not_found' = 'No '.$typeName.' found', 'not_found_in_trash' = 'No '.$typeName.' found in Trash', 'parent_item_colon' = '', 'menu_name' = $typeName ); }   // register post type args function tj_custom_post_type_args($typeName,$postType="post",$public=true,$queryable=true,$show_ui=true,$show_menu=true,$query_var=true,$has_archive = true, $hierarchical = false,$menu_position = null){ return $args = array( 'labels' = tj_cutom_post_type_label_args($typeName), 'public' = $public, 'publicly_queryable' = $queryable, 'show_ui' = $show_ui, 'show_in_menu' = $show_menu, 'query_var' = $query_var, 'rewrite' = array( 'slug' = strtolower($typeName)), 'capability_type' = $postType, 'has_archive' = $has_archive, 'hierarchical' = $hierarchical, 'menu_position' = $menu_position, 'supports' = array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) ); }
function tj_custom_post_type() { register_post_type( 'portfolio', tj_custom_post_type_args("Portfolio")); register_post_type( 'testimonials', tj_custom_post_type_args("Testimonials")); } add_action( 'init', 'tj_custom_post_type' );


在线客服

关闭

客户服务热线
4008-888-888


点击这里给我发消息 在线客服

点击这里给我发消息 在线客服