Advertisement
TheD4h101

Wordpress Custom Post Type

Apr 24th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. //////////////////////////////////////////////////////////////////
  2.  
  3. // Register blogs post type
  4.  
  5. //////////////////////////////////////////////////////////////////
  6.  
  7. add_action( 'init', 'register_blogs_post_type' );
  8.  
  9.  
  10.  
  11. function register_blogs_post_type() {
  12.  
  13. register_post_type( 'blogs',
  14.  
  15. array(
  16.  
  17. 'labels' => array(
  18.  
  19. 'name' => __( 'Blogs' ),
  20.  
  21. 'singular_name' => __( 'Blog' ),
  22.  
  23. 'add_new' => __( 'Add New' ),
  24.  
  25. 'add_new_item' => __( 'Add New Blog' ),
  26.  
  27. 'edit' => __( 'Edit' ),
  28.  
  29. 'edit_item' => __( 'Edit Blog' ),
  30.  
  31. 'new_item' => __( 'New Blog' ),
  32.  
  33. 'view' => __( 'View Blog' ),
  34.  
  35. 'view_item' => __( 'View Blog' ),
  36.  
  37. 'search_items' => __( 'Search blogs' ),
  38.  
  39. 'not_found' => __( 'No Blogs found' ),
  40.  
  41. 'not_found_in_trash' => __( 'No Blogs found in Trash' ),
  42.  
  43. 'parent' => __( 'Parent Blog' ),
  44.  
  45. ),
  46.  
  47. 'public' => true,
  48.  
  49. 'show_ui' => true,
  50.  
  51. 'publicly_queryable' => true,
  52.  
  53. 'show_in_nav_menus' => false,
  54.  
  55. 'exclude_from_search' => false,
  56.  
  57. 'hierarchical' => false,
  58.  
  59. 'rewrite' => array('slug'=>'blog'),
  60.  
  61. 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'author'),
  62.  
  63. 'taxonomies' => array('post_tag')
  64.  
  65. )
  66.  
  67. );
  68.  
  69. flush_rewrite_rules();
  70.  
  71. }
  72.  
  73.  
  74.  
  75. //////////////////////////////////////////////////////////////////
  76.  
  77. // Register blogs category taxonomy
  78.  
  79. //////////////////////////////////////////////////////////////////
  80.  
  81. add_action( 'init', 'create_blog_category', 0 );
  82.  
  83.  
  84.  
  85. function create_blog_category()
  86.  
  87. {
  88.  
  89.  
  90.  
  91. $labels = array(
  92.  
  93. 'name' => _x( 'Blog Categories', 'taxonomy general name' ),
  94.  
  95. 'singular_name' => _x( 'Blog Category', 'taxonomy singular name' ),
  96.  
  97. 'search_items' => __( 'Search Blog Categories' ),
  98.  
  99. 'all_items' => __( 'All Blog Categories' ),
  100.  
  101. 'parent_item' => __( 'Parent Blog Category' ),
  102.  
  103. 'parent_item_colon' => __( 'Parent Blog Category:' ),
  104.  
  105. 'edit_item' => __( 'Edit Blog Category' ),
  106.  
  107. 'update_item' => __( 'Update Blog Category' ),
  108.  
  109. 'add_new_item' => __( 'Add New Blog Category' ),
  110.  
  111. 'new_item_name' => __( 'New Blog Category Name' ),
  112.  
  113. 'menu_name' => __( 'Categories' ),
  114.  
  115. );
  116.  
  117.  
  118.  
  119. register_taxonomy('blog_category',array('blogs'), array(
  120.  
  121. 'hierarchical' => true,
  122.  
  123. 'labels' => $labels,
  124.  
  125. 'show_ui' => true,
  126.  
  127. 'query_var' => true,
  128.  
  129. ));
  130.  
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement