Skip to content

Instantly share code, notes, and snippets.

@AlkarE
Last active August 29, 2015 14:25
Show Gist options
  • Save AlkarE/0a48136f2c6962ec5bee to your computer and use it in GitHub Desktop.
Save AlkarE/0a48136f2c6962ec5bee to your computer and use it in GitHub Desktop.
custom_post_plugin
<?php
/*Plugin Name: Create Picture post type and Album category
Description: This plugin registers the 'Picture' post type.
Version: 1.0
License: GPLv2
*/
function picture_post_type() {
$labels = array(
'name' => 'Picture',
'singular_name' => 'Picture',
'add_new' => 'Add New Picture',
'add_new_item' => 'Add New Picture',
'edit_item' => 'Edit Picture',
'new_item' => 'New Picture',
'all_items' => 'All Pictures',
'view_item' => 'View Picture',
'search_items' => 'Search Pictures',
'not_found' => 'No Pictures Found',
'not_found_in_trash' => 'No Pictures found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Picture',
);
//register post type
register_post_type( 'picture', array(
'labels' => $labels,
'has_archive' => true,
'public' => true,
'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail','page-attributes' ),
'taxonomies' => array( 'post_tag', 'category' ),
'exclude_from_search' => false,
'capability_type' => 'post',
'rewrite' => array( 'slug' => 'picture' ),
)
);
}
add_action( 'init', 'picture_post_type' );
function art_album_register_taxonomy() {
// set up labels
$labels = array(
'name' => 'Album',
'singular_name' => 'Album',
'search_items' => 'Search Albums',
'all_items' => 'All Albums',
'edit_item' => 'Edit Album',
'update_item' => 'Update Album',
'add_new_item' => 'Add New Album',
'new_item_name' => 'New Album',
'menu_name' => 'Albums'
);
// register taxonomy
register_taxonomy( 'albumcat', 'picture', array(
'hierarchical' => true,
'labels' => $labels,
'query_var' => true,
'show_admin_column' => true
) );
}
add_action( 'init', 'art_album_register_taxonomy' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment