Communities Custom Post Type
// Register Custom Post Type
function create_communities_cpt() {
$labels = array(
'name' => _x( 'Communities', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Community', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Communities', 'text_domain' ),
'name_admin_bar' => __( 'Communities', 'text_domain' ),
'parent_item_colon' => __( 'Parent Community:', 'text_domain' ),
'all_items' => __( 'All Communities', 'text_domain' ),
'add_new_item' => __( 'Add New Community', 'text_domain' ),
'add_new' => __( 'Add New', 'text_domain' ),
'new_item' => __( 'New Community', 'text_domain' ),
'edit_item' => __( 'Edit Community', 'text_domain' ),
'update_item' => __( 'Update Community', 'text_domain' ),
'view_item' => __( 'View Community', 'text_domain' ),
'search_items' => __( 'Search Community', 'text_domain' ),
'not_found' => __( 'Not found', 'text_domain' ),
'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
);
$rewrite = array(
'slug' => 'community',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$capabilities = array(
'edit_post' => 'edit_community',
'read_post' => 'read_community',
'delete_post' => 'delete_community',
'edit_posts' => 'edit_communities',
'edit_others_posts' => 'edit_others_communities',
'publish_posts' => 'publish_communities',
'read_private_posts' => 'read_private_communities',
);
$args = array(
'label' => __( 'communities_cpt', 'text_domain' ),
'description' => __( 'Add community pages to show off value added for featured properties', 'text_domain' ),
'labels' => $labels,
'supports' => array( 'title', 'author', 'thumbnail', 'revisions', ),
'taxonomies' => array( 'listings_cpt' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'communities',
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capabilities' => $capabilities,
);
register_post_type( 'communities_cpt', $args );
}
// Hook into the 'init' action
add_action( 'init', 'create_communities_cpt', 0 );