/** * @override */ public function register_fields() { parent::register_fields(); // Custom fields register_rest_field($this->_postTypeName, 'xp', array('get_callback' => array($this, 'get_xp'))); register_rest_field($this->_postTypeName, 'perk_points', array('get_callback' => array($this, 'get_perk_points'))); register_rest_field($this->_postTypeName, 'energy', array('get_callback' => array($this, 'get_energy_points'))); register_rest_field($this->_postTypeName, 'starting_skill', array('update_callback' => array($this, 'initialize_character'))); }
function checkForPostType() { $property_type = new CPT('property', array('supports' => array('title', 'editor', 'thumbnail', 'comments', 'custom-fields'))); if (!post_type_exists('property')) { $property_type->register_taxonomy(array('type' => 'Property Type')); } }
function setupCustomPostTypes() { $global_cpt_args = array('has_archive' => true, 'menu_position' => 3, 'public' => true, 'show_in_nav_menus' => true, 'supports' => array('title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions')); $ecoregion = new CPT(array('post_type_name' => 'ecoregion', 'singular' => 'Ecoregion', 'plural' => 'Ecoregions', 'slug' => 'ecoregion'), array_merge($global_cpt_args, array('menu_position' => 4))); $ecoregion->menu_icon('dashicons-admin-site'); $kci = new CPT(array('post_type_name' => 'kci', 'singular' => 'KCI', 'plural' => 'KCIs', 'slug' => 'key-conservation-issue'), array_merge($global_cpt_args, array('menu_position' => 6))); $kci->menu_icon('dashicons-admin-network'); //$kci->add_admin_columns(array('post_id'=>'post_id')); $coa = new CPT(array('post_type_name' => 'coa', 'singular' => 'COA', 'plural' => 'COAs', 'slug' => 'conservation-opportunity-area'), array_merge($global_cpt_args, array('menu_position' => 9))); $coa->menu_icon('dashicons-editor-ul'); $strategy_habitat = new CPT(array('post_type_name' => 'strategy_habitat', 'singular' => 'Strategy Habitat', 'plural' => 'Strategy Habitats', 'slug' => 'strategy-habitat'), array_merge($global_cpt_args, array('menu_position' => 7))); $strategy_habitat->menu_icon('dashicons-format-image'); $ss_options = array_merge($global_cpt_args, array('menu_position' => 8, 'hierarchical' => true, 'taxonomies' => array('species'), 'supports' => array('title', 'editor', 'author', 'thumbnail', 'page-attributes'))); $strategy_species = new CPT(array('post_type_name' => 'strategy_species', 'singular' => 'Strategy Species', 'plural' => 'Strategy Species', 'slug' => 'strategy-species'), $ss_options); $strategy_species->menu_icon('dashicons-id'); $success_story = new CPT(array('post_type_name' => 'success_story', 'singular' => 'Strategy Spotlight', 'plural' => 'Strategy Spotlights', 'slug' => 'success-story'), array_merge($global_cpt_args, array('menu_position' => 9))); $success_story->menu_icon('dashicons-format-chat'); }
/** * Create a custom post type. * * @param mixed $post_type_names The name(s) of the post type, accepts (post type name, slug, plural, singular). * @param array $options User submitted options. */ public function create($post_type_names, $options = array()) { $cpt = new \CPT($post_type_names, $options = array()); $cpt->set_textdomain($this->framework->getTextDomain()); return $cpt; }
<?php /* Plugin Name: Team members Plugin URI: Description: This plugin lets you add team members. Author: Rushdi Version: 1.0 Author URI: http://www.github.com/rushdi1987/ */ defined('ABSPATH') or die('No script kiddies please!'); // include the custom post type class include_once 'class-post-type.php'; // create a member custom post type $members = new CPT('member', array('supports' => array('title', 'excerpt', 'thumbnail'))); // create a department taxonomy $members->register_taxonomy('department'); // define the columns to appear on the admin edit screen $members->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'department' => __('Departments'), 'price' => __('Price'), 'rating' => __('Rating'), 'date' => __('Date'), 'age' => __('Age'), 'location' => __('Location'))); // populate the price column $members->populate_column('price', function ($column, $post) { echo "£" . get_field('price'); // ACF get_field() function }); // populate the ratings column $members->populate_column('rating', function ($column, $post) { echo get_field('rating') . '/5'; // ACF get_field() function }); // populate the ratings column $members->populate_column('location', function ($column, $post) {
*/ $schedule = new CPT('schedule'); // Schedule taxonomy $schedule->register_taxonomy('schedule_year'); // Schedule columns $schedule->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'schedule_year' => __('Festival Year'), 'date' => __('Date'))); $schedule->sortable(array('schedule_year' => array('schedule_year', true))); // Schedule icon $schedule->menu_icon("dashicons-schedule"); $schedule->menu_position(7); /** * ---------------- * SPONSORS * ---------------- */ $sponsors = new CPT('sponsor'); // Sponsors taxonomy $sponsors->register_taxonomy('level'); // Sponsors columns $sponsors->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'level' => __('Sponsor Level'), 'date' => __('Date'))); $sponsors->sortable(array('level' => array('level', true))); // Sponsors menu $sponsors->menu_icon("dashicons-heart"); $sponsors->menu_position(8); /** * Shortcodes * --------------------------------------------------------------------------- */ // SPONSORS - [sponsors level="premuium" columns="3"] add_shortcode('sponsors', 'postsponsors'); function postsponsors($atts)
<?php $portfolio = new CPT(array('post_type_name' => 'portfolio', 'singular' => __('Portfolio', 'ta-portfolio'), 'plural' => __('Portfolios', 'ta-portfolio'), 'slug' => 'portfolio'), array('supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), 'menu_icon' => 'dashicons-portfolio')); $portfolio->register_taxonomy(array('taxonomy_name' => 'portfolio_tags', 'singular' => __('Portfolio Tag', 'ta-portfolio'), 'plural' => __('Portfolio Tags', 'ta-portfolio'), 'slug' => 'portfolio-tag'));
<?php $shows = new CPT('album', array('supports' => array('title', 'thumbnail'))); $shows->menu_icon('dashicons-format-audio');
<?php $shows = new CPT('show', array('supports' => array('title', 'thumbnail'))); $shows->menu_icon('dashicons-calendar-alt');
<?php /* Plugin Name: Hangging Garden of Bali PLugin Plugin URI: http://alamaya.com Version: 1.0 Description: This plugin is required for Hangging Garden of Bali template Author: The Alamaya Team Author URI: http://alamaya.com Domain Path: /languages License: MIT */ require_once 'inc/CPT.php'; $villa = new CPT('villa', array('supports' => array('title', 'editor', 'thumbnail', 'comments', 'excerpt'), 'rewrite' => array('slug' => 'ubudvillas'))); $villa->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'date' => __('Date'))); $villa->menu_icon("dashicons-pressthis"); $news = new CPT('news', array('supports' => array('title', 'editor', 'thumbnail', 'comments', 'excerpt'))); $news->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'date' => __('Date'))); $news->menu_icon("dashicons-pressthis");
<?php $news = new CPT('post'); $news->register_taxonomy(array('taxonomy_name' => 'secao', 'slug' => 'secao', 'singular' => 'Seção', 'plural' => 'Seções')); $news_tax_secao = new SetRobot_Taxonomy_Single_Term('secao', array($news->post_type_name), 'select'); $news_tax_secao->set('metabox_title', 'Escolha a seção da notícia'); $news_tax_secao->set('priority', 'high'); $news_tax_secao->set('allow_new_terms', true); $args = array("applied_label" => "Arquivado", "label" => "Arquivo"); new CustomPostStatus('archive', array($news->post_type_name), $args);
<?php include_once 'CPT.php'; $retreats = new CPT('retreat', array('supports' => array('title', 'editor', 'thumbnail'), 'show_in_menu' => true, 'menu_position' => 5)); $retreats->menu_icon('dashicons-palmtree'); $retreats->register_taxonomy('retreat_type'); $retreats->filters(array('retreat_type')); $services = new CPT('service', array('supports' => array('title', 'editor', 'thumbnail'), 'show_in_menu' => true, 'menu_position' => 5)); $services->menu_icon('dashicons-share-alt');
<?php /** * Register custom post types here. * For more info see: https://github.com/jjgrainger/wp-custom-post-type-class */ // example post type $books = new CPT('book', array('supports' => array('title', 'editor', 'thumbnail', 'comments'))); // example custom taxonomy for books $books->register_taxonomy('genres');
<?php /** * Instatiate the Slider Post Type * @var CPT */ $slides = new CPT(array('post_type_name' => 'slider'), array('supports' => array('title'), 'menu_icon' => 'dashicons-welcome-view-site', 'public' => false, 'show_ui' => true, 'show_in_rest' => true)); // Add Columns to Admin $slides->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'shortcode' => __('Shortcode'), 'id' => __('ID'), 'date' => __('Date'))); // Populate Shortcode Column $slides->populate_column('shortcode', function ($column, $post) { echo "<pre>[slideshow id=\"" . $post->ID . '"]</pre>'; }); // Populate ID Column $slides->populate_column('id', function ($column, $post) { echo $post->ID; }); // Add the ACF Fields if (!class_exists('acf_pro')) { include_once get_template_directory() . '/inc/acf/acf.php'; } if (function_exists('acf_add_local_field_group')) { // Slider Options acf_add_local_field_group(array('key' => 'group_5625f53b88b2a', 'title' => 'Slider Options', 'fields' => array(array('key' => 'field_5625f82bf1aac', 'label' => 'UI Features', 'name' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'placement' => 'top', 'endpoint' => 0), array('key' => 'field_5625f54ce518e', 'label' => 'Enable Features', 'name' => 'slider_enable_features', 'type' => 'checkbox', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 100, 'class' => '', 'id' => ''), 'choices' => array('dots' => 'Navigation Dots', 'arrows' => 'Navigation Arrows', 'infinite' => 'Infinite Loop', 'pauseOnHover' => 'Pause On Hover', 'pauseOnDotsHover' => 'Pause On Navigation Hover', 'adaptiveHeight' => 'Adaptive Height', 'draggable' => 'Draggable', 'autoplay' => 'AutoPlay', 'fade' => 'Fade'), 'default_value' => array(), 'layout' => 'vertical', 'toggle' => 0), array('key' => 'field_5635ef26c90c4', 'label' => 'Slide Transition Speed', 'name' => 'slide_transition_speed', 'type' => 'number', 'instructions' => 'Speed (in ms) for transition speed.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'default_value' => 500, 'placeholder' => '', 'prepend' => '', 'append' => 'ms', 'min' => 100, 'max' => '', 'step' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_5635efa0c5fb5', 'label' => 'Slide Autoplay Speed', 'name' => 'slide_autoplayspeed', 'type' => 'number', 'instructions' => 'Duration (in ms) between slides when autoplay is enabled.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'default_value' => 3000, 'placeholder' => '', 'prepend' => '', 'append' => 'ms', 'min' => 500, 'max' => '', 'step' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_5625f84ef1aad', 'label' => 'Size', 'name' => 'size', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'placement' => 'top', 'endpoint' => 0), array('key' => 'field_5625f6bdc5613', 'label' => 'Width', 'name' => 'slider_container', 'type' => 'radio', 'instructions' => 'Select a container style to display this slider.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'choices' => array('full_width' => 'Full Width (Useful for image sliders)', 'constrained' => 'Full Width - Constrained Content', 'boxed' => 'Boxed (Useful within content as shortcode)'), 'other_choice' => 0, 'save_other_choice' => 0, 'default_value' => 'full_width', 'layout' => 'vertical'), array('key' => 'field_5625f861f1aae', 'label' => 'Colors', 'name' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'placement' => 'top', 'endpoint' => 0), array('key' => 'field_5625f757c5614', 'label' => 'Background Color', 'name' => 'slider_container_background', 'type' => 'color_picker', 'instructions' => 'Choose a background color for your slider.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'default_value' => '#EEEEEE'), array('key' => 'field_562b1c5b847a9', 'label' => 'Text Color', 'name' => 'slider_textcolor', 'type' => 'color_picker', 'instructions' => 'Choose a text color for your slider.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'default_value' => '#FFFFFF'), array('key' => 'field_5625f9fd8d759', 'label' => 'Background Image', 'name' => 'slider_container_background_image', 'type' => 'image', 'instructions' => 'Choose a background color for your slider.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'return_format' => 'url', 'preview_size' => 'medium', 'library' => 'all', 'min_width' => '', 'min_height' => '', 'min_size' => '', 'max_width' => '', 'max_height' => '', 'max_size' => '', 'mime_types' => ''), array('key' => 'field_562b1cac30823', 'label' => 'Background Repeat', 'name' => 'slider_container_background_repeat', 'type' => 'select', 'instructions' => 'Slider Background placement.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'choices' => array('no-repeat' => 'Don\'t Tile', 'repeat' => 'Tile Horizontally and Vertically', 'repeat-x' => 'Tile Horizontally', 'repeat-y' => 'Tile Vertically'), 'default_value' => array('no-repeat' => 'no-repeat'), 'allow_null' => 0, 'multiple' => 0, 'ui' => 0, 'ajax' => 0, 'placeholder' => '', 'disabled' => 0, 'readonly' => 0), array('key' => 'field_5625f8f056182', 'label' => 'Advanced', 'name' => 'advanced', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'placement' => 'top', 'endpoint' => 0), array('key' => 'field_5625f8fc56183', 'label' => 'CSS Class', 'name' => 'slider_css_class', 'type' => 'text', 'instructions' => 'Add a class for unique styling of this slider via CSS.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'default_value' => 'theme-slide-example', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0)), 'location' => array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'slider'))), 'menu_order' => 0, 'position' => 'acf_after_title', 'style' => 'default', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => 1, 'description' => '')); // Slider Fields acf_add_local_field_group(array('key' => 'group_5625c6eb50a96', 'title' => 'Slider', 'fields' => array(array('key' => 'field_5625c993a9203', 'label' => 'Slides', 'name' => 'slide', 'type' => 'repeater', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'collapsed' => 'field_5625c9a2a9204', 'min' => '', 'max' => '', 'layout' => 'block', 'button_label' => 'Add Slide', 'sub_fields' => array(array('key' => 'field_5625cafc1bb1f', 'label' => 'Slide Options', 'name' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'placement' => 'top', 'endpoint' => 0), array('key' => 'field_5625cb2b1bb21', 'label' => 'Slide Content Type', 'name' => 'slide_type', 'type' => 'radio', 'instructions' => 'Choose a slide content type. Options in the following tab will change based on the settings made here.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'choices' => array('image_slide' => 'Image Slide', 'content_slide' => 'Content Slide', 'video_slide' => 'Video Slide'), 'other_choice' => 0, 'save_other_choice' => 0, 'default_value' => 'content_slide', 'layout' => 'vertical'), array('key' => 'field_562b1e2032909', 'label' => 'Slide Class', 'name' => 'slide_class', 'type' => 'text', 'instructions' => 'Optional custom CSS to be applied for advanced styling.', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_5625cb1e1bb20', 'label' => 'Slide Content', 'name' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'placement' => 'top', 'endpoint' => 0), array('key' => 'field_5625c9a2a9204', 'label' => 'Heading', 'name' => 'slide_heading', 'type' => 'text', 'instructions' => 'Title text for the slide.', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'content_slide'))), 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_5625c9cda9205', 'label' => 'Content', 'name' => 'slide_content', 'type' => 'wysiwyg', 'instructions' => 'Content for this slide', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'content_slide'))), 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'default_value' => '', 'tabs' => 'all', 'toolbar' => 'simple', 'media_upload' => 1), array('key' => 'field_5625c9f9a9206', 'label' => 'Image', 'name' => 'slide_content_image', 'type' => 'image', 'instructions' => 'Image for this slide. Best aspect ratio is 4:3 or 16:9.', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'content_slide'))), 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'return_format' => 'array', 'preview_size' => 'medium', 'library' => 'all', 'min_width' => '', 'min_height' => '', 'min_size' => '', 'max_width' => '', 'max_height' => '', 'max_size' => '', 'mime_types' => ''), array('key' => 'field_5625d401faaf6', 'label' => 'Image Align', 'name' => 'slide_content_image_align', 'type' => 'radio', 'instructions' => 'For content slides with images, choose which side of the slide your image will be aligned.', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'content_slide'))), 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'choices' => array('align_left' => 'Align Left', 'align_right' => 'Align Right'), 'other_choice' => 0, 'save_other_choice' => 0, 'default_value' => '', 'layout' => 'horizontal'), array('key' => 'field_5625d5ba4c2bd', 'label' => 'Slide Image', 'name' => 'slide_fullwidth_image', 'type' => 'image', 'instructions' => 'Add a full width Image for this slide. For best results, size should be a minimum of 1400px.', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'image_slide'))), 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'return_format' => 'array', 'preview_size' => 'medium', 'library' => 'all', 'min_width' => '', 'min_height' => '', 'min_size' => '', 'max_width' => '', 'max_height' => '', 'max_size' => '', 'mime_types' => ''), array('key' => 'field_5625ca19a9207', 'label' => 'Button', 'name' => 'slide_button_text', 'type' => 'text', 'instructions' => 'Optional button to appear with this slide', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'content_slide'))), 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_5625ca4aa9208', 'label' => 'URL', 'name' => 'slide_url', 'type' => 'text', 'instructions' => 'URL to visit on when slide elements are clicked', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'image_slide')), array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'content_slide'))), 'wrapper' => array('width' => 50, 'class' => '', 'id' => ''), 'default_value' => 'http://', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_56385f2e0dde1', 'label' => 'Display Caption', 'name' => 'display_caption', 'type' => 'true_false', 'instructions' => 'Displays an optional heading/caption centered above the image.', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'image_slide'))), 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'message' => '', 'default_value' => 0), array('key' => 'field_5625cd6ae1774', 'label' => 'Video', 'name' => 'slide_video', 'type' => 'oembed', 'instructions' => '', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'video_slide'))), 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'width' => '', 'height' => ''), array('key' => 'field_5638612e6e522', 'label' => 'Caption', 'name' => '', 'type' => 'tab', 'instructions' => '', 'required' => 0, 'conditional_logic' => array(array(array('field' => 'field_5625cb2b1bb21', 'operator' => '==', 'value' => 'image_slide'), array('field' => 'field_56385f2e0dde1', 'operator' => '==', 'value' => '1'))), 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'placement' => 'top', 'endpoint' => 0), array('key' => 'field_563860c076fee', 'label' => 'Slide Caption Heading', 'name' => 'slide_caption_heading', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_563860d576ff0', 'label' => 'Slide Caption', 'name' => 'slide_caption', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0), array('key' => 'field_5638617a4b874', 'label' => 'Slide Button Text', 'name' => 'slide_caption_button_text', 'type' => 'text', 'instructions' => '', 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array('width' => '', 'class' => '', 'id' => ''), 'default_value' => '', 'placeholder' => '', 'prepend' => '', 'append' => '', 'maxlength' => '', 'readonly' => 0, 'disabled' => 0)))), 'location' => array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'slider'))), 'menu_order' => 1, 'position' => 'acf_after_title', 'style' => 'default', 'label_placement' => 'top', 'instruction_placement' => 'label', 'hide_on_screen' => '', 'active' => 1, 'description' => '')); } // Add the slider to the wp rest api // function slider_rest_args() { // global $wp_post_types; // $wp_post_types['slider']->show_in_rest = true;
<?php $book = new CPT(array('post_type_name' => 'books', 'singular' => __('Book'), 'plural' => __('Books'), 'slug' => 'books'), array('supports' => array('title', 'editor', 'author', 'thumbnail'), 'menu_icon' => 'dashicons-book')); $book->register_taxonomy(array('taxonomy_name' => 'genre', 'singular' => __('Genre'), 'plural' => __('Genres'), 'slug' => 'genre'));
/** * Constructor * * Register a custom post type. * * @param mixed $post_type_names The name(s) of the post type, accepts (post type name, slug, plural, singular). * @param array $options User submitted options. */ public function add($post_type_names, $options = array()) { $cpt = new \CPT($post_type_names, $options); $cpt->set_textdomain(ANUNATHEME_TEXTDOMAIN); return $cpt; }
public function register_event() { $event = new CPT('event'); $event->menu_icon('dashicons-calendar'); $event->register_taxonomy('event-type'); }
<?php // Register shows Post Type $shows = new CPT('show', array('supports' => array('title', 'thumbnail'))); $music = new CPT('album', array('supports' => array('title', 'thumbnail'))); $shows->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'show_date' => __('Date'), 'venue' => __('Venue'), 'city' => __('City'), 'state' => __('State'))); $shows->populate_column('show_date', function ($column, $post) { echo get_field('show_date'); }); $shows->populate_column('venue', function ($column, $post) { echo get_field('show_venue'); }); $shows->populate_column('city', function ($column, $post) { echo get_field('show_city'); }); $shows->populate_column('state', function ($column, $post) { echo get_field('show_state'); }); $shows->sortable(array('date' => array('meta_key', true)));
<?php include_once 'CPT.php'; // Work CPT // create work custom post type $work = new CPT(array('post_type_name' => 'work', 'singular' => 'Work', 'plural' => 'Work', 'slug' => 'work'), array('supports' => array('author', 'title', 'editor', 'thumbnail', 'excerpt', 'comments'), 'has_archive' => true, 'capability_type' => 'post', 'show_in_menu' => true)); // use icon for post type $work->menu_icon("dashicons-portfolio"); $work->register_taxonomy('type'); $work->register_taxonomy('tag'); /* * Testimonial CPT */ // create testimonial custom post type $testimonial = new CPT(array('post_type_name' => 'testimonial', 'singular' => 'Testimonial', 'plural' => 'Testimonials', 'slug' => 'testimonials'), array('supports' => array('author', 'title', 'editor', 'thumbnail', 'excerpt', 'comments'), 'has_archive' => true, 'capability_type' => 'post', 'show_in_menu' => true)); // use icon for post type $testimonial->menu_icon("dashicons-format-quote");
* Custom Post Type Class Setup * * @package _s */ /** * Load the CPT class */ include_once get_template_directory() . '/inc/vendor/wp-custom-post-type-class/src/CPT.php'; // Dashicons for 'menu_icon' value can be found here: // https://developer.wordpress.org/resource/dashicons /** * CPT: Photos */ $photo_labels = array('post_type_name' => 'photo', 'singular' => 'Photo', 'plural' => 'Photos', 'slug' => 'photos'); $photo_options = array('public' => true, 'has_archive' => true, 'supports' => array('revisions', 'thumbnail', 'title'), 'rewrite' => array('slug' => 'photos'), 'menu_icon' => 'dashicons-camera'); $photo = new CPT($photo_labels, $photo_options); /** * Tax: Photo Category */ $photo->register_taxonomy(array('taxonomy_name' => 'photo_category', 'singular' => 'Photo Category', 'plural' => 'Photo Categories', 'slug' => 'photo-category')); /** * Featured image column */ $cpts = array($photo); // add column to each $cpt setup variable if ($cpts) { foreach ($cpts as $cpt) { $cpt->columns(array('cb' => '<input type="checkbox" />', 'title' => __('Title'), 'feat_img' => __('Featured Image'), 'p_cat' => __('Category'), 'author' => __('Author'), 'date' => __('Date'))); $cpt->populate_column('feat_img', function ($column, $post) { if (has_post_thumbnail()) { the_post_thumbnail(array(64, 64));