<?php/** * Plugin Name: Directory Custom Post Type * Description: Custom Post Type for an employee directory. Requires customization to the active theme to display custom fields. * Version: 1.0 * License: GPL2 */// Prevent direct access to this filedefined('ABSPATH')ordie('No script kiddies please!');functionpz_employee_custom_post_type(){/** * Hero Images for the Front Page * Theme will need to be configured using WP Query to use this tool */$labels=array('name'=>'Directory','singular_name'=>'Employee','menu_name'=>'Directory','name_admin_bar'=>'Employee','add_new'=>'Add an Employee','add_new_item'=>'Add an Employee','new_item'=>'New Employee','edit_item'=>'Edit Employee','view_item'=>'View Employee','all_items'=>'All Employees','search_items'=>'Search Employees','parent_item_colon'=>'Parent Employees:','not_found'=>'No Employees found.','not_found_in_trash'=>'No Employee entries found in Trash.',);$args=array('labels'=>$labels,'public'=>false,'publicly_queryable'=>true,'show_ui'=>true,'show_in_menu'=>true,'menu_icon'=>'dashicons-groups','query_var'=>true,'rewrite'=>array('slug'=>'directory'),'capability_type'=>'post','has_archive'=>true,'hierarchical'=>true,'menu_position'=>5,'show_in_rest'=>true,'supports'=>array('title','editor','thumbnail','custom-fields','page-attributes'),'taxonomies'=>array('category'),);register_post_type('employees',$args);}add_action('init','pz_employee_custom_post_type');// Flush rewrite to add as a permalink slug when plugin is activated or reactiviated.functionpz_rewrite_flush(){pz_employee_custom_post_type();flush_rewrite_rules();}register_activation_hook(__FILE__,'pz_rewrite_flush');/**DisablesAdvancedCustomFieldsdefaultpreferencetohidecustomfields*Thisallowstheusertoaddstandardcustomfieldsthatcanbeaddedtothe*activethemesuchasemailaddress,officelocationetc.if(function_exists('get_field')){add_filter('acf/settings/remove_wp_meta_box','__return_false');}
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.