예제 #1
0
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'));
    }
}
<?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");
예제 #3
0
 public function register_event()
 {
     $event = new CPT('event');
     $event->menu_icon('dashicons-calendar');
     $event->register_taxonomy('event-type');
 }
/*
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) {
    echo get_post_field('location', $post->ID) . ', Bangladesh';
// 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)
{
    extract(shortcode_atts(array('level' => '', 'columns' => '', 'mobile' => ''), $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'));
예제 #7
0
/**
 * 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));
            }
        });
        $cpt->populate_column('p_cat', function ($column, $post) {
            echo get_the_term_list($post->ID, 'photo_category', '', ', ', '');
예제 #8
0
파일: post.php 프로젝트: cc-mkt/setrobot
<?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);
예제 #9
0
<?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');
예제 #10
0
<?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');
예제 #11
0
<?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'));