No Comments - Mar 27, 2019

A sample code how to create your own CPT (Custom Post Type) using functions.php

<?php

/************************************/
// CREATE CPT PROJECTS / START
/************************************/

function my_custom_post_projects() {
	$labels = array(
		'name'               => _x( 'Projects', 'post type general name' ),
		'singular_name'      => _x( 'Projects', 'post type singular name' ),
		'add_new'            => _x( 'Add New', 'Project' ),
		'add_new_item'       => __( 'Add New Projects' ),
		'edit_item'          => __( 'Edit Project' ),
		'new_item'           => __( 'New Project' ),
		'all_items'          => __( 'All Projects' ),
		'view_item'          => __( 'View Projects' ),
		'search_items'       => __( 'Search Projects' ),
		'not_found'          => __( 'No Projects found' ),
		'not_found_in_trash' => __( 'No Projects found in the Trash' ), 
		'parent_item_colon'  => '',
		'menu_name'          => 'Project'
	);
	
	
	$args = array(
		'labels'        => $labels,
		'description'   => 'For Projects only',
		'public'        => true, // make it false if you would like to unaccessible outside...
//		"show_in_rest" => false,		
//		"publicly_queryable" => false,
//		"show_ui" => true,
//		"rest_base" => "",	
		'menu_position' => 5,
		'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments'),
		'has_archive'   => true,
		'menu_icon'     => 'dashicons-shield',
		'rewrite' => array( 'slug' => 'projects' )
	);
	register_post_type( 'projects', $args );	
}
add_action( 'init', 'my_custom_post_projects' );

?>

Please support the 2fxmedia.net by downloading the most secure browser called Brave Browser please click here to download the browser and install the browser.. Don’t forget to visit the 2fxmedia.net using brave browser and don’t forget to make a tip to 2fxmedia.net Cheers!

If you are happy with this post you can donate a bit coin for my site. Simply click the link below

1Eq3Gf1ZkNK7KN66eGArThYhEc81sfeWNH Donate BTC 1Eq3Gf1ZkNK7KN66eGArThYhEc81sfeWNH 1Eq3Gf1ZkNK7KN66eGArThYhEc81sfeWNH

Leave a Comment

Your email address will not be published. Fields with * are required.