Last active
June 28, 2021 13:29
-
-
Save shaunpalmer/48d3573eb708498af3b878e9b403780f to your computer and use it in GitHub Desktop.
Register Custom Post Type Plus Variables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//change to the right function name | |
function spwp_register_post_type() { | |
$singular = 'members Page'; //change to the right post type name | |
$plural = 'members Page'; //change to the right post type names | |
$detailed_description = 'description'; //change to the right description | |
$textdomain = 'sp-ps-td-shaun-palmer'; //change to the right text domain | |
$spwp_post_type = 'spwp_register_post_type'; //change to the right function name | |
$labels = array( | |
'name' => $plural, | |
'singular_name' => $singular, | |
'add_name' => 'Add New' | |
'add_new_item' => 'Add New '. $singular, | |
'edit' => 'Edit', | |
'edit_item' => 'Edit'. $singular, | |
'new_item' 'view' => 'view'. $singular, | |
'view_item' => 'View'. $singular, | |
'search_term' => 'Search'. $plural, | |
'parent' => 'Parent'. $singular, | |
'not_found' => 'No'. $plural .'found', | |
'not_found_in_trash' => 'No'. $plural .'in Trash', | |
); | |
$rewrite = array( | |
'slug' => 'mbp', | |
'with_front' => true, | |
'pages' => true, | |
'feeds' => false, | |
); | |
$args = array( | |
'label' => __( $plural, . $textdomain ), | |
'description' => __( $detailed_description .'This is a collection of all the custom post type pages hosted on this website', . $textdomain ), | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats','wp-block-styles' ), | |
'taxonomies' => array( "category", 'link_category',"post_tag", 'attachment_category', 'post_format' ), | |
'hierarchical' => true, | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'show_in_rest' => true, | |
'menu_position' => 10, | |
'menu_icon' => 'dashicons-welcome-widgets-menus', | |
'show_in_admin_bar' => true, | |
'show_in_nav_menus' => true, | |
'can_export' => true, | |
'has_archive' => true, | |
'exclude_from_search' => true, | |
'publicly_queryable' => true, | |
'rewrite' => $rewrite, | |
'capability_type' => 'page', | |
); | |
); | |
register_post_type( $spwp_post_type, $args ); | |
} | |
add_action( 'init', .$spwp_post_type , 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment