Skip to content

Instantly share code, notes, and snippets.

@shaunpalmer
Last active June 26, 2021 05:39
Show Gist options
  • Save shaunpalmer/7729337a44d49d1e8a89f3c862e9aa9d to your computer and use it in GitHub Desktop.
Save shaunpalmer/7729337a44d49d1e8a89f3c862e9aa9d to your computer and use it in GitHub Desktop.
members_cpt
<?php
/*
* Plugin Name: members_cpt
Plugin URI:https://shaunpalmer.co.nz
Description: members_cpt Custom Post Type & taxonomies that adds custom post types
Version: 0.1.6
Author: shaun palmer
Author URI: [email protected]
Text Domain: sp-ps-td-shaun-palmer
*Tested up to: 5.1
*/
//=================================================
// Security: Abort if this file is called directly
//=================================================
if ( ! defined( 'WPINC' ) ) {
die;
}
//=================================================
// Security: Exit if accessed directly if this file is called directly
//=================================================
if(!defined('ABSPATH')){
exit; // Exit if accessed directly
return;
}
// members Custome type
if ( ! function_exists('members_cpt_custom_post_type') ) {
// Register Custom Post Type
function members_cpt_custom_post_type() {
$labels = array(
'name' => _x( 'members Pages', 'Post Type General Name', 'sp-ps-td-shaun-palmer' ),
'singular_name' => _x( 'members Page', 'Post Type Singular Name', 'sp-ps-td-shaun-palmer' ),
'menu_name' => __( 'members Pages', 'sp-ps-td-shaun-palmer' ),
'name_admin_bar' => __( 'members Pages', 'sp-ps-td-shaun-palmer' ),
'archives' => __( 'members Page Archives', 'sp-ps-td-shaun-palmer' ),
'parent_item_colon' => __( 'Parent members Page:', 'sp-ps-td-shaun-palmer' ),
'all_items' => __( 'All members Pages', 'sp-ps-td-shaun-palmer' ),
'add_new_item' => __( 'Add New members Page', 'sp-ps-td-shaun-palmer' ),
'add_new' => __( 'Add New', 'sp-ps-td-shaun-palmer' ),
'new_item' => __( 'New members Page', 'sp-ps-td-shaun-palmer' ),
'edit_item' => __( 'Edit members Page', 'sp-ps-td-shaun-palmer' ),
'update_item' => __( 'Update members Page', 'sp-ps-td-shaun-palmer' ),
'view_item' => __( 'View members Page', 'sp-ps-td-shaun-palmer' ),
'search_items' => __( 'Search members Page', 'sp-ps-td-shaun-palmer' ),
'not_found' => __( 'Not found', 'sp-ps-td-shaun-palmer' ),
'not_found_in_trash' => __( 'Not found in Trash', 'sp-ps-td-shaun-palmer' ),
'featured_image' => __( 'Featured Image', 'sp-ps-td-shaun-palmer' ),
'set_featured_image' => __( 'Set featured image', 'sp-ps-td-shaun-palmer' ),
'remove_featured_image' => __( 'Remove featured image', 'sp-ps-td-shaun-palmer' ),
'use_featured_image' => __( 'Use as featured image', 'sp-ps-td-shaun-palmer' ),
'insert_into_item' => __( 'Insert into members Page', 'sp-ps-td-shaun-palmer' ),
'uploaded_to_this_item' => __( 'Uploaded to this members Page', 'sp-ps-td-shaun-palmer' ),
'items_list' => __( 'members Page list', 'sp-ps-td-shaun-palmer' ),
'items_list_navigation' => __( 'members Page list navigation', 'sp-ps-td-shaun-palmer' ),
'filter_items_list' => __( 'Filter members Page list', 'sp-ps-td-shaun-palmer' ),
);
$rewrite = array(
'slug' => 'mbp',
'with_front' => true,
'pages' => true,
'feeds' => false,
);
$args = array(
'label' => __( 'members Page', 'sp-ps-td-shaun-palmer' ),
'description' => __( 'This is a collection of all the members pages hosted on this website', 'sp-ps-td-shaun-palmer' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
'taxonomies' => array( 'link_category', 'post_format' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 10,
'menu_icon' => 'dashicons-welcome-widgets-menus',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'show_in_rest' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => true,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'members_page_cpt', $args );
}
add_action( 'init', 'members_cpt_custom_post_type', 0 );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment