Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Forked from mrjonwilson/properties-cpt.php
Last active August 30, 2016 13:55
Show Gist options
  • Save joshfeck/8f4b58a5cbb62af3499fbfb574ddf535 to your computer and use it in GitHub Desktop.
Save joshfeck/8f4b58a5cbb62af3499fbfb574ddf535 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: Custom Post Type Plugin
Description: Properties Custom Post Type.
*/
/*
* Creating a function to create our CPT
*/
function mrj_property_custom_post_type() {
// Set UI labels for Custom Post Type
$labels = array(
'name' => _x( 'Properties', 'Post Type General Name', 'fl-automator' ),
'singular_name' => _x( 'Property', 'Post Type Singular Name', 'fl-automator' ),
'menu_name' => __( 'Properties', 'fl-automator' ),
'parent_item_colon' => __( 'Parent Property', 'fl-automator' ),
'all_items' => __( 'All Properties', 'fl-automator' ),
'view_item' => __( 'View Property', 'fl-automator' ),
'add_new_item' => __( 'Add New Property', 'fl-automator' ),
'add_new' => __( 'Add New', 'fl-automator' ),
'edit_item' => __( 'Edit Property', 'fl-automator' ),
'update_item' => __( 'Update Property', 'fl-automator' ),
'search_items' => __( 'Search Property', 'fl-automator' ),
'not_found' => __( 'Not Found', 'fl-automator' ),
'not_found_in_trash' => __( 'Not found in Trash', 'fl-automator' ),
);
// Set other options for Custom Post Type
$args = array(
'label' => __( 'properties', 'fl-automator' ),
'description' => __( 'Property news and reviews', 'fl-automator' ),
'labels' => $labels,
// Features this CPT supports in Post Editor
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'revisions', ),
// You can associate this CPT with a taxonomy or custom taxonomy.
'taxonomies' => array( 'genres' ),
/* A hierarchical CPT is like Pages and can have
* Parent and child items. A non-hierarchical CPT
* is like Posts.
*/
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-location-alt',
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'page',
);
// Registering your Custom Post Type
register_post_type( 'properties', $args );
}
/* Hook into the 'init' action so that the function
* Containing our post type registration is not
* unnecessarily executed.
*/
add_action( 'init', 'mrj_property_custom_post_type' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment