|
@@ -50,9 +50,9 @@ function custom_post_example() {
|
|
|
) /* end of options */
|
|
) /* end of options */
|
|
|
); /* end of register post type */
|
|
); /* end of register post type */
|
|
|
|
|
|
|
|
- /* this ads regular categories to your custom post type */
|
|
|
|
|
|
|
+ /* this ads your post categories to your custom post type */
|
|
|
register_taxonomy_for_object_type('category', 'custom_type');
|
|
register_taxonomy_for_object_type('category', 'custom_type');
|
|
|
- /* this ads regular tags to your custom post type */
|
|
|
|
|
|
|
+ /* this ads your post tags to your custom post type */
|
|
|
register_taxonomy_for_object_type('post_tag', 'custom_type');
|
|
register_taxonomy_for_object_type('post_tag', 'custom_type');
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -60,10 +60,15 @@ function custom_post_example() {
|
|
|
// adding the function to the Wordpress init
|
|
// adding the function to the Wordpress init
|
|
|
add_action( 'init', 'custom_post_example');
|
|
add_action( 'init', 'custom_post_example');
|
|
|
|
|
|
|
|
- // now let's add custom categories (http://codex.wordpress.org/Function_Reference/register_taxonomy)
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ for more information on taxonomies, go here:
|
|
|
|
|
+ http://codex.wordpress.org/Function_Reference/register_taxonomy
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+ // now let's add custom categories (these act like categories)
|
|
|
register_taxonomy( 'custom_cat',
|
|
register_taxonomy( 'custom_cat',
|
|
|
array('custom_type'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
|
|
array('custom_type'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
|
|
|
- array('hierarchical' => true,
|
|
|
|
|
|
|
+ array('hierarchical' => true, /* if this is true it acts like categories
|
|
|
'labels' => array(
|
|
'labels' => array(
|
|
|
'name' => __( 'Custom Categories' ), /* name of the custom taxonomy */
|
|
'name' => __( 'Custom Categories' ), /* name of the custom taxonomy */
|
|
|
'singular_name' => __( 'Custom Category' ), /* single taxonomy name */
|
|
'singular_name' => __( 'Custom Category' ), /* single taxonomy name */
|
|
@@ -80,6 +85,27 @@ function custom_post_example() {
|
|
|
'query_var' => true,
|
|
'query_var' => true,
|
|
|
)
|
|
)
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
|
|
+ // now let's add custom tags (these act like categories)
|
|
|
|
|
+ register_taxonomy( 'custom_tag',
|
|
|
|
|
+ array('custom_type'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
|
|
|
|
|
+ array('hierarchical' => false, /* if this is false, it acts like tags */
|
|
|
|
|
+ 'labels' => array(
|
|
|
|
|
+ 'name' => __( 'Custom Tags' ), /* name of the custom taxonomy */
|
|
|
|
|
+ 'singular_name' => __( 'Custom Tag' ), /* single taxonomy name */
|
|
|
|
|
+ 'search_items' => __( 'Search Custom Tags' ), /* search title for taxomony */
|
|
|
|
|
+ 'all_items' => __( 'All Custom Tags' ), /* all title for taxonomies */
|
|
|
|
|
+ 'parent_item' => __( 'Parent Custom Tag' ), /* parent title for taxonomy */
|
|
|
|
|
+ 'parent_item_colon' => __( 'Parent Custom Tag:' ), /* parent taxonomy title */
|
|
|
|
|
+ 'edit_item' => __( 'Edit Custom Tag' ), /* edit custom taxonomy title */
|
|
|
|
|
+ 'update_item' => __( 'Update Custom Tag' ), /* update title for taxonomy */
|
|
|
|
|
+ 'add_new_item' => __( 'Add New Custom Tag' ), /* add new title for taxonomy */
|
|
|
|
|
+ 'new_item_name' => __( 'New Custom Tag Name' ) /* name title for taxonomy */
|
|
|
|
|
+ ),
|
|
|
|
|
+ 'show_ui' => true,
|
|
|
|
|
+ 'query_var' => true,
|
|
|
|
|
+ )
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
?>
|