Created
April 22, 2012 11:03
Revisions
-
GreenGeorge revised this gist
Apr 22, 2012 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,7 +28,6 @@ function add_post_type($name, $args = array() ) { }; // ***** Declare function that builds the taxonomy function add_taxonomy($name, $post_type, $args = array()) { add_action('init', function() use($name, $post_type, $args) { -
GreenGeorge revised this gist
Apr 22, 2012 . No changes.There are no files selected for viewing
-
GreenGeorge created this gist
Apr 22, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ <?php // ***** Declare function that buids the post type function add_post_type($name, $args = array() ) { add_action('init',function() use($name, $args) { // make post type name capitalized $upper = ucwords($name); // make name acceptable $name = strtolower(str_replace(' ', '_', $name)); // merge default args with passed args $args = array_merge( array( 'public' => true, 'label' => ucwords("$name" . 's'), 'labels' => array( 'add_new_item' => "Add New $upper" . ''), 'supports' => array( 'title','editor','excerpt'), 'taxonomies' => array('category') ),$args); // build post type register_post_type($name, $args ); }); }; // ***** Declare function that builds the taxonomy function add_taxonomy($name, $post_type, $args = array()) { add_action('init', function() use($name, $post_type, $args) { // make taxonomy name capitalized $upper = ucwords($name); $plural = ucwords("$name" . 's'); // make name acceptable $name = strtolower(str_replace(' ', '_', $name)); // merge default args with passed args $args = array_merge(array( 'label' => $plural, ),$args); register_taxonomy($name, $post_type, $args); }); };