<?php/** * Plugin Name: JD Project * Description: Custom Post Type for portfolio projects * Version: 1.0 * License: GPL2 */// Prevent direct access to this filedefined('ABSPATH')ordie('No script kiddies please!');/** * https://developer.wordpress.org/reference/functions/register_post_type/ */functionjd_project_custom_post_type(){$labels=array('name'=>'Projects','singular_name'=>'Project','menu_name'=>'Project','name_admin_bar'=>'Project','add_new'=>'Add new Project','add_new_item'=>'Add new Project','new_item'=>'New Project','edit_item'=>'Edit Project','view_item'=>'View Project','all_items'=>'All Projects','search_items'=>'Search Projects','parent_item_colon'=>'Parent Projects:','not_found'=>'No Projects found.','not_found_in_trash'=>'No Projects found in Trash.',);$args=array('labels'=>$labels,'public'=>true,'publicly_queryable'=>true,'show_ui'=>true,'show_in_menu'=>true,'menu_icon'=>'dashicons-index-card','query_var'=>true,'rewrite'=>array('slug'=>'project'),'capability_type'=>'post','has_archive'=>true,'hierarchical'=>true,'menu_position'=>17,'show_in_rest'=>true,'supports'=>array('title','editor','thumbnail','excerpt','trackbacks','revisions','page-attributes'),);register_post_type('project',$args);}add_action('init','jd_project_custom_post_type');// Flush rewrite rules when plugin is activatedfunctionjd_project_rewrite_flush(){jd_project_custom_post_type();flush_rewrite_rules();}register_activation_hook(__FILE__,'jd_project_rewrite_flush');if(function_exists('add_theme_support')){add_theme_support('post-thumbnails');}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.