WordPress注册自定义post类型代码
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了WordPress注册自定义post类型代码相关的知识,希望对你有一定的参考价值。
// Register Custom Post Type // snippet updated 6/3/2011 // Bare Bones // -- from Ian Stewart at bit.ly/wppoweredby function powered_by_create_post_type() { 'public' => true, ) ); } add_action( 'init', 'powered_by_create_post_type' ); // Basic and Quick // -- from Konstantin Kovshenin at bit.ly/kovcpt // -- also see Justin Tadlock at bit.ly/jtadcpt // -- and Custom Post Type Generator at bit.ly/generate-wpcpt // Fire this during init 'label' => __('Foos'), 'singular_label' => __('Foo'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, )); // Full and Comprehensive // -- generated with the Custom Post Type Generator at bit.ly/generate-wpcpt add_action( 'init', 'register_cpt_foo' ); function register_cpt_foo() { 'name' => _x( 'Foos', 'foo' ), 'singular_name' => _x( 'foo', 'foo' ), 'add_new' => _x( 'Add New', 'foo' ), 'add_new_item' => _x( 'Add New foo', 'foo' ), 'edit_item' => _x( 'Edit foo', 'foo' ), 'new_item' => _x( 'New foo', 'foo' ), 'view_item' => _x( 'View foo', 'foo' ), 'search_items' => _x( 'Search Foos', 'foo' ), 'not_found' => _x( 'No foos found', 'foo' ), 'not_found_in_trash' => _x( 'No foos found in Trash', 'foo' ), 'parent_item_colon' => _x( 'Parent foo:', 'foo' ), 'menu_name' => _x( 'Foos', 'foo' ), ); 'labels' => $labels, 'hierarchical' => true, 'description' => 'These are foos.', 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => true, 'capability_type' => 'post' ); register_post_type( 'foo', $args ); } // end
以上是关于WordPress注册自定义post类型代码的主要内容,如果未能解决你的问题,请参考以下文章