Return to Snippet

Revision: 59827
at October 3, 2012 23:37 by SidFerreiraZ


Initial Code
//Register the custom post type
register_post_type( 'my_custom_type',
  array(
    'labels' => array(
      'name' => _x('Custom Type Items', 'post type general name'),
      'singular_name' => _x('Custom Type', 'post type singular name'),
      'add_new' => _x('Add New', 'custom_type'),
      'add_new_item' => __('Add New Item'),
      'edit_item' => __('Edit Item'),
      'new_item' => __('New Item'),
      'all_items' => __('All Items'),
      'view_item' => __('View item'),
      'search_items' => __('Search item'),
      'not_found' =>  __('No items found'),
      'not_found_in_trash' => __('No items found in trash'),
      'parent_item_colon' => '',
      'menu_name' => 'Custom Type',
    ),
    'supports' => array('title'),
    'public' => true,
  )
);

//Register categories for the custom type
register_taxonomy( 'my_custom_type_categories', 'my_custom_type', array(
  'hierarchical' => true,
  'label' => __( 'Categories for Custom Type' ),
  'show_ui' => true
  )
);


$cat = get_terms('my_custom_type_categories'); //All categories for post type

$q = new WP_Query (array ('taxonomy'=>'my_custom_type_categories','term'=> $cat->slug)); //Posts from the taxonomy

Initial URL


Initial Description
Wordpress Custom Post Type, custom taxonomy and queries

Initial Title
Wordpress Custom Post Type, custom taxonomy and queries

Initial Tags
php, wordpress

Initial Language
PHP