Skip to content

Instantly share code, notes, and snippets.

@hellofromtonya
Created January 25, 2022 13:58
Show Gist options
  • Save hellofromtonya/9615b8a50928c0c8935949c53736785a to your computer and use it in GitHub Desktop.
Save hellofromtonya/9615b8a50928c0c8935949c53736785a to your computer and use it in GitHub Desktop.
Basic CPT plugin
<?php
/**
* Test CPT with TT2.
*
* Plugin Name: Test CPT
* Plugin URI: https://github.com/tester/testcpt/
* Description: Tests custom post type blank screen with TT2
* Version: 1.0
* Author: tester
* Author URI: https://github.com/tester/testcpt/
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
* Text Domain: testcpt
* Domain Path: /languages
* Requires at least: 4.9
* Requires PHP: 5.6 or later
*/
namespace TestCPT;
if ( ! defined( 'ABSPATH' ) ) {
die( 'Invalid request.' );
}
function register_custom_post_type() {
register_post_type( 'testcpt',
array(
'labels' => array(
'name' => __( 'TestCPT', 'testcpt' ),
'singular_name' => __( 'TestCPT', 'testcpt' ),
),
'public' => true,
'has_archive' => true,
'show_in_rest' => true,
'rewrite' => array( 'slug' => 'testcpt' )
)
);
}
add_action( 'init', __NAMESPACE__ . '\register_custom_post_type' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment