Posted By

tomdowning on 09/21/11


Tagged

wordpress


Versions (?)

WP custom post_type & taxonomy


 / Published in: PHP
 

  1. function customPostType($posttype, $name, $tax, $supports) {
  2. $labels = array(
  3. 'name' => _x($name, 'post type general name'),
  4. 'singular_name' => _x($name, 'post type singular name'),
  5. 'add_new' => _x('Add New', strtolower($name) . ' item'),
  6. 'add_new_item' => __('Add New ' . $name),
  7. 'edit_item' => __('Edit ' . $name),
  8. 'new_item' => __('New ' . $name),
  9. 'view_item' => __('View ' . $name),
  10. 'search_items' => __('Search ' . $name),
  11. 'not_found' => __('Nothing found'),
  12. 'not_found_in_trash' => __('Nothing found in Trash'),
  13. 'parent_item_colon' => ''
  14. );
  15.  
  16. $rewrite = false;
  17. if($posttype=='collections' || $posttype=='agency') $rewrite = array('with_front'=>false);
  18. $args = array(
  19. 'labels' => $labels,
  20. 'public' => true,
  21. 'publicly_queryable' => true,
  22. 'show_ui' => true,
  23. 'query_var' => true,
  24. //'menu_icon' => get_stylesheet_directory_uri() . '/article16.png',
  25. 'rewrite' => $rewrite,
  26. 'capability_type' => 'page',
  27. 'hierarchical' => true,
  28. 'menu_position' => null,
  29. 'supports' => $supports
  30. );
  31.  
  32. register_post_type($posttype,$args);
  33. }
  34.  
  35. function customTaxonomy($name, $query_var, $slug, $label, $posttype, $singular) {
  36. register_taxonomy($name, $posttype, array( "hierarchical" => true,
  37. "label" => $label,
  38. "singular_label" => $singular,
  39. "query_var" => $query_var,
  40. "rewrite" => false
  41. ));
  42. }

Report this snippet  

You need to login to post a comment.