Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Piklist Taxonomy Tussle
<?php
/*
Title: Post Submit
Method: post
Message: Ninja saved. View here: <a href="/coolninja/">Ninja List</a>
*/
// Where to save this form
piklist('field', array(
'type' => 'hidden'
,'scope' => 'post'
,'field' => 'post_type'
,'value' => 'coolninja'
));
// These are the usual elements, as Piklist fields ------------------------
piklist( 'field', array(
'type' => 'text'
,'scope' => 'post'
,'field' => 'post_title'
,'label' => 'Ninja name'
));
...
// These are the taxonomies with scope asserted ----------------
piklist( 'field', array(
'type' => 'text'
,'scope' => 'taxonomy'
,'field' => 'ninjacolor'
,'label' => 'Ninja Color'
));
piklist( 'field', array(
'type' => 'text'
,'scope' => 'taxonomy'
,'field' => 'ninjaelement'
,'label' => 'Ninja Element'
));
piklist( 'field', array(
'type' => 'text'
,'scope' => 'taxonomy'
,'field' => 'ninjaskill'
,'label' => 'Ninja Skill'
));
// These set post status to publish, and creates the submit button ----------
piklist('field', array(
'type' => 'hidden'
,'scope' => 'post'
,'field' => 'post_status'
,'value' => 'publish'
));
piklist('field', array(
'type' => 'submit'
,'field' => 'submit'
,'value' => 'Submit'
));
?>
<?php
// These set the cpt and taxonomies ----------
<?php
/*
Plugin Name: coolninja
Plugin URI: http://rhust.com/coolninja
Description: This is the core of onecoolninja.
Version: 0.1
Author: Robert Hust
Author URI: http://rhust.com
Plugin Type: Piklist
License: GPL2
*/
add_filter('piklist_post_types', 'ocn_post_type');
function ocn_post_type($post_types)
{
$post_types['coolninja'] = array(
'labels' => piklist('post_type_labels', 'CoolNinja')
,'title' => __('Enter a new title')
,'menu_icon' => 'dashicons-universal-access-alt'
,'public' => true
,'has_archive' => true
,'rewrite' => array('slug' => 'coolninja')
,'supports' => array('title','editor','excerpt','author','revisions')
,'taxonomies' => array('ninjacolor','ninjaelement','ninjaskill')
);
return $post_types;
}
add_filter('piklist_taxonomies', 'ninja_taxonomies');
function ninja_taxonomies($taxonomies){
$taxonomies[] = array(
'post_type' => 'coolninja'
,'name' => 'ninjacolor'
,'configuration' => array(
'hierarchical' => true
,'labels' => piklist('taxonomy_labels', 'Colors')
,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png'
,'show_ui' => true
,'query_var' => true
,'rewrite' => array(
'slug' => 'ninjacolor'
)
,'show_admin_column' => true
,'list_table_filter' => true
,'meta_box_filter' => true
,'comments' => true
)
);
$taxonomies[] = array(
'post_type' => 'coolninja'
,'name' => 'ninjaelement'
,'configuration' => array(
'hierarchical' => true
,'labels' => piklist('taxonomy_labels', 'Elements')
,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png'
,'show_ui' => true
,'query_var' => true
,'rewrite' => array(
'slug' => 'ninjaelement'
)
,'show_admin_column' => true
,'list_table_filter' => true
,'meta_box_filter' => true
,'comments' => true
)
);
$taxonomies[] = array(
'post_type' => 'coolninja'
,'name' => 'ninjaskill'
,'configuration' => array(
'hierarchical' => true
,'labels' => piklist('taxonomy_labels', 'Skills')
,'page_icon' => piklist('url', 'piklist') . '/parts/img/piklist-page-icon-32.png'
,'show_ui' => true
,'query_var' => true
,'rewrite' => array(
'slug' => 'ninjaskill'
)
,'show_admin_column' => true
,'list_table_filter' => true
,'meta_box_filter' => true
,'comments' => true
)
);
return $taxonomies;
}
// I've tried 'hierarchical' => false as well
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.