function cftl_register_taxonomies_to_tax_landing() { global $wp_taxonomies; foreach ($wp_taxonomies as $taxonomy) { register_taxonomy_for_object_type($taxonomy->name, 'cftl-tax-landing'); } }
function collegePress_register_custom_post_types() { register_post_type('pcm_tournament', array('menu_icon' => 'dashicons-megaphone', 'labels' => array('name' => __('Tournaments'), 'singular_name' => __('Tournament')), 'public' => true, 'has_archive' => true, 'menu_position' => 5, 'rewrite' => array('slug' => 'tournaments'), 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'))); register_taxonomy_for_object_type('tournaments', 'pcm_tournament'); register_post_type('pcm_event', array('menu_icon' => 'dashicons-calendar-alt', 'labels' => array('name' => __('Events'), 'singular_name' => __('event')), 'public' => true, 'has_archive' => true, 'menu_position' => 5, 'rewrite' => array('slug' => 'events'), 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'))); register_taxonomy_for_object_type('events', 'pcm_event'); }
/** * All code that runs when our plugin is first activated. * * We're going to register all the custom post types and taxonomies we'll need. * We'll all set up permalinks (@todo) and add some default content (@todo) so we have a country list to start. * * @package Wanderlist */ function wanderlist_custom_data() { /** * First, we're going to register a 'location' Custom Post Type. * This forms the basis of our plugin. */ $location_labels = array('name' => _x('Places', 'Post Type General Name', 'wanderlist'), 'singular_name' => _x('Place', 'Post Type Singular Name', 'wanderlist'), 'menu_name' => __('Wanderlist', 'wanderlist'), 'all_items' => __('Places', 'wanderlist'), 'new_item_name' => __('New Place', 'wanderlist'), 'add_new_item' => __('Add New Place', 'wanderlist'), 'edit_item' => __('Edit Place', 'wanderlist'), 'update_item' => __('Update Place', 'wanderlist'), 'view_item' => __('View Place', 'wanderlist'), 'not_found' => __('Not Found', 'wanderlist')); $location_args = array('label' => __('place', 'wanderlist'), 'description' => __('Places you have been and places you are.', 'wanderlist'), 'menu_icon' => 'dashicons-location', 'labels' => $location_labels, 'supports' => array(), 'taxonomies' => array('post_tag', 'wanderlist-trip', 'wanderlist-country'), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'capability_type' => 'post', 'rewrite' => array('slug' => 'places'), 'register_meta_box_cb' => 'wanderlist_extra_metaboxes', 'supports' => array('title', 'editor', 'thumbnail', 'excerpt')); register_post_type('wanderlist-location', $location_args); /** * Register countries as a taxonomy, so we can count 'em. */ $country_labels = array('name' => _x('Countries', 'Taxonomy General Name', 'wanderlist'), 'singular_name' => _x('Country', 'Taxonomy Singular Name', 'wanderlist'), 'menu_name' => __('Countries', 'wanderlist'), 'all_items' => __('All Countries', 'wanderlist'), 'parent_item' => __('Parent Country', 'wanderlist'), 'parent_item_colon' => __('Parent Country:', 'wanderlist'), 'new_item_name' => __('New Country Name', 'wanderlist'), 'add_new_item' => __('Add New Country', 'wanderlist'), 'edit_item' => __('Edit Country', 'wanderlist'), 'update_item' => __('Update Country', 'wanderlist'), 'view_item' => __('View Country', 'wanderlist'), 'separate_items_with_commas' => __('Separate countries with commas', 'wanderlist'), 'add_or_remove_items' => __('Add or remove countries', 'wanderlist'), 'choose_from_most_used' => __('Choose from the most used', 'wanderlist'), 'popular_items' => __('Popular Countries', 'wanderlist'), 'search_items' => __('Search Countries', 'wanderlist'), 'not_found' => __('Not Found', 'wanderlist')); $country_args = array('labels' => $country_labels, 'hierarchical' => true, 'public' => true, 'show_ui' => false, 'show_admin_column' => false, 'show_in_nav_menus' => true, 'show_tagcloud' => true); register_taxonomy('wanderlist-country', array('post', 'wanderlist-location'), $country_args); register_taxonomy_for_object_type('wanderlist-country', 'wanderlist-location'); /** * Register a taxonomy for trips, so we can map out a particular trip. * This just allows us an easy way to group locations and travels into * different trips. * At some point, we'll add functionality to show full details of a * particular trip. */ $trip_labels = array('name' => _x('Trips', 'Taxonomy General Name', 'wanderlist'), 'singular_name' => _x('Trip', 'Taxonomy Singular Name', 'wanderlist'), 'menu_name' => __('Trips', 'wanderlist'), 'all_items' => __('All Trips', 'wanderlist'), 'new_item_name' => __('New Trip Name', 'wanderlist'), 'add_new_item' => __('Add New Trip', 'wanderlist'), 'edit_item' => __('Edit Trip', 'wanderlist'), 'update_item' => __('Update Trip', 'wanderlist'), 'view_item' => __('View Trip', 'wanderlist'), 'separate_items_with_commas' => __('Separate trips with commas', 'wanderlist'), 'add_or_remove_items' => __('Add or remove trips', 'wanderlist'), 'choose_from_most_used' => __('Choose from the most used trips', 'wanderlist'), 'popular_items' => __('Popular trips', 'wanderlist'), 'search_items' => __('Search trips', 'wanderlist'), 'not_found' => __('Not Found', 'wanderlist')); $trip_args = array('labels' => $trip_labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true); register_taxonomy('wanderlist-trip', array('post', 'wanderlist-location'), $trip_args); register_taxonomy_for_object_type('wanderlist-trip', 'wanderlist-location'); }
function gdlr_init_page_feature() { add_post_type_support('page', 'excerpt'); // create page categories register_taxonomy('page_category', array("page"), array('hierarchical' => true, 'label' => __('Page Categories', 'gdlr_translate'), 'singular_label' => __('Page Category', 'gdlr_translate'), 'rewrite' => array('slug' => 'page_category'))); register_taxonomy_for_object_type('page_category', 'page'); }
function custom_taxonomy_Item() { $labels = array('name' => 'Items', 'singular_name' => 'Item', 'menu_name' => 'Item', 'all_items' => 'All Items', 'parent_item' => 'Parent Item', 'parent_item_colon' => 'Parent Item:', 'new_item_name' => 'New Item Name', 'add_new_item' => 'Add New Item', 'edit_item' => 'Edit Item', 'update_item' => 'Update Item', 'separate_items_with_commas' => 'Separate Item with commas', 'search_items' => 'Search Items', 'add_or_remove_items' => 'Add or remove Items', 'choose_from_most_used' => 'Choose from the most used Items'); $args = array('labels' => $labels, 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, 'show_in_nav_menus' => true, 'show_tagcloud' => true); register_taxonomy('item', 'product', $args); register_taxonomy_for_object_type('item', 'product'); }
function nicdark_add_taxonomy_packages() { register_taxonomy_for_object_type('destination-package', 'packages'); register_taxonomy_for_object_type('typology-package', 'packages'); register_taxonomy_for_object_type('duration-package', 'packages'); register_taxonomy_for_object_type('person-package', 'packages'); }
public function __construct($name = null, $post_types = array(), $args = array(), $capabilities = array(), $labels = array()) { $this->taxonomy_name = Custom_Post_Type::uglify($name); $this->taxonomy_post_types = $post_types; $this->taxonomy_args = $args; $this->taxonomy_capabilities = $capabilities; $this->taxonomy_labels = $labels; if (!taxonomy_exists($this->taxonomy_name)) { $name = Custom_Post_Type::beautify($name); $plural = Custom_Post_Type::pluralize($name); $labels = array_merge(array('name' => _x($plural, 'taxonomy general name'), 'singular_name' => _x($name, 'taxonomy singular name'), 'search_items' => __('Search ' . $plural), 'all_items' => __('All ' . $plural), 'parent_item' => __('Parent ' . $name), 'parent_item_colon' => __('Parent ' . $name . ':'), 'edit_item' => __('Edit ' . $name), 'update_item' => __('Update ' . $name), 'add_new_item' => __('Add New ' . $name), 'new_item_name' => __('New ' . $name . ' Name'), 'menu_name' => __($name)), $this->taxonomy_labels); $capabilities = $this->merge_caps($this->taxonomy_args, $this->taxonomy_capabilities); // Default arguments, overwritten with the given arguments $args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, '_builtin' => false, 'capabilities' => $capabilities), $this->taxonomy_args); // Add the taxonomy to the post types add_action('init', function () use($args) { register_taxonomy($this->taxonomy_name, $this->taxonomy_post_types, $args); }); } else { /* The taxonomy already exists. We are going to attach the existing taxonomy to the object type (post type) */ add_action('init', function () { foreach ($this->taxonomy_post_types as $type) { register_taxonomy_for_object_type($this->taxonomy_name, $type); } }); } }
public function register() { $labels = array('name' => _x('Event Categories', 'taxonomy general name', 'iworks_event'), 'singular_name' => _x('Event Category', 'taxonomy singular name', 'iworks_event'), 'search_items' => __('Search Event Categories', 'iworks_event'), 'popular_items' => __('Popular Event Categories', 'iworks_event'), 'all_items' => __('All Event Categories', 'iworks_event'), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __('Edit Event Category', 'iworks_event'), 'update_item' => __('Update Event Category', 'iworks_event'), 'add_new_item' => __('Add New Event Category', 'iworks_event'), 'new_item_name' => __('New Event Category Name', 'iworks_event'), 'separate_items_with_commas' => __('Separate places with commas', 'iworks_event'), 'add_or_remove_items' => __('Add or remove places', 'iworks_event'), 'choose_from_most_used' => __('Choose from the most used event categories', 'iworks_event'), 'not_found' => __('No event categories found.', 'iworks_event'), 'menu_name' => __('Event Categories', 'iworks_event')); $args = array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => 'ecat')); register_taxonomy($this->taxonomy, null, $args); register_taxonomy_for_object_type($this->taxonomy, $this->post_type); }
function custom_post_example() { register_post_type('custom_type', array('labels' => array('name' => __('Custom Types', 'efreetanttheme'), 'singular_name' => __('Custom Post', 'efreetanttheme'), 'all_items' => __('All Custom Posts', 'efreetanttheme'), 'add_new' => __('Add New', 'efreetanttheme'), 'add_new_item' => __('Add New Custom Type', 'efreetanttheme'), 'edit' => __('Edit', 'efreetanttheme'), 'edit_item' => __('Edit Post Types', 'efreetanttheme'), 'new_item' => __('New Post Type', 'efreetanttheme'), 'view_item' => __('View Post Type', 'efreetanttheme'), 'search_items' => __('Search Post Type', 'efreetanttheme'), 'not_found' => __('Nothing found in the Database.', 'efreetanttheme'), 'not_found_in_trash' => __('Nothing found in Trash', 'efreetanttheme'), 'parent_item_colon' => ''), 'description' => __('This is the example custom post type', 'efreetanttheme'), 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_ui' => true, 'query_var' => true, 'menu_position' => 8, 'menu_icon' => get_stylesheet_directory_uri() . '/library/images/custom-post-icon.png', 'rewrite' => array('slug' => 'custom_type', 'with_front' => false), 'has_archive' => 'custom_type', 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'sticky'))); /* end of register post type */ register_taxonomy_for_object_type('category', 'custom_type'); register_taxonomy_for_object_type('post_tag', 'custom_type'); }
function pinegrow_docs_init() { // Use categories with attachments register_taxonomy_for_object_type('category', 'attachment'); register_taxonomy('frameworks', array('post', 'page'), array('label' => __('Frameworks'), 'rewrite' => array('slug' => 'framework'))); register_taxonomy('workingwith', array('post', 'page'), array('label' => __('Working with'), 'rewrite' => array('slug' => 'working-with'))); register_taxonomy('blocks', array('post', 'page'), array('label' => __('Blocks'), 'rewrite' => array('slug' => 'blocks'))); register_taxonomy('wordpress', array('post', 'page'), array('label' => __('WordPress'), 'rewrite' => array('slug' => 'wordpress'))); /* * Register custom post types. You can also move this code to a plugin. */ /* Pinegrow generated Custom Post Types Begin */ /* Pinegrow generated Custom Post Types End */ if (!function_exists('mytheme_customize_register')) { function mytheme_customize_register($wp_customize) { /* Pinegrow generated Customizer Controls Begin */ $wp_customize->add_section('home_custo', array('title' => __('Homepage', 'pinegrow_docs'), 'description' => __('Homepage Settings', 'pinegrow_docs'))); $wp_customize->add_setting('home_intro', array('type' => 'theme_mod', 'default' => 'Pinegrow is a desktop app that lets you build responsive websites faster with live multi-page editing, CSS styling and smart components for Bootstrap, Foundation, AngularJS and WordPress.')); $wp_customize->add_control('home_intro', array('label' => __('Home Intro Text', 'pinegrow_docs'), 'type' => 'textarea', 'section' => 'home_custo')); /* Pinegrow generated Customizer Controls End */ } add_action('customize_register', 'mytheme_customize_register'); } /* Pinegrow generated Register Sidebars Begin */ register_sidebar(array('name' => __('Sidebar', 'pinegrow_docs'), 'id' => 'docs-sidebar', 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h3 class="widgettitle">', 'after_title' => '</h3>')); /* Pinegrow generated Register Sidebars End */ }
function wp_leads_add_cats_and_tags() { // Add tag metabox to page register_taxonomy_for_object_type('post_tag', 'page'); // Add category metabox to page register_taxonomy_for_object_type('category', 'page'); }
/** * Register the taxonomy, this should be called on the init hook * * @param string The name of the post type to register this taxonomy */ public function register($post_type) { if (!taxonomy_exists($this->taxonomy)) { register_taxonomy($this->taxonomy, $post_type, $this->taxonomy_args); } register_taxonomy_for_object_type($this->taxonomy, $post_type); }
public static function onInit() { if (!empty(static::$_to_unregister)) { foreach (static::$_to_unregister as $taxonomy) { global $wp_taxonomies; if (static::exists($taxonomy)) { unset($wp_taxonomies[$taxonomy]); } } } if (!empty(static::$_to_register)) { foreach (static::$_to_register as $taxonomy => $option) { register_taxonomy($taxonomy, $option['object_type'], $option['args']); } } if (!empty(static::$_to_unregister_to_post_type)) { foreach (static::$_to_unregister_to_post_type as $taxonomy => $post_types) { foreach ($post_types as $post_type) { unregister_taxonomy_for_object_type($taxonomy, $post_type); } } } if (!empty(static::$_to_register_to_post_type)) { foreach (static::$_to_register_to_post_type as $taxonomy => $post_types) { foreach ($post_types as $post_type) { register_taxonomy_for_object_type($taxonomy, $post_type); } } } }
public function init_postType() { $labels = array('name' => __('Testy'), 'singular_name' => __('Test'), 'add_new' => __('Nový záznam'), 'add_new_item' => __('Přidat nový záznam'), 'edit_item' => __('Upravit'), 'new_item' => __('Nový záznam'), 'view_item' => __('Upravit záznam'), 'search_items' => __('Vyhledat'), 'not_found' => __('Nic nenalezeno'), 'not_found_in_trash' => __('Nic nenalezeno')); $args = array('labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'query_var' => true, 'menu_icon' => 'dashicons-editor-paste-text', 'menu_position' => 20, 'capability_type' => 'post', 'taxonomies' => array('category'), 'hierarchical' => true, 'show_in_menu' => true); register_post_type($this->postType, $args); register_taxonomy_for_object_type('category', $this->postType); }
/** * Registers the post taxonomies with the bp_docs post type * * @since 1.0-beta * * @param array The $bp_docs_post_type_args array created in BP_Docs::register_post_type() * @return array $args The modified parameters */ function register_with_post_type() { $this->taxonomies = array($this->docs_tag_tax_name); foreach ($this->taxonomies as $tax) { register_taxonomy_for_object_type($tax, bp_docs_get_post_type_name()); } }
function create_post_type_bnb_apartment() { register_taxonomy_for_object_type('category', 'bnb_apartment'); // Register Taxonomies for Category register_taxonomy_for_object_type('post_tag', 'bnb_apartment'); register_post_type('bnb_apartment', array('labels' => array('name' => __('Apartments', 'bnb_apartment'), 'singular_name' => __('Apartment', 'bnb_apartment'), 'add_new' => __('Add New', 'bnb_apartment'), 'add_new_item' => __('Add New Apartment', 'bnb_apartment'), 'edit' => __('Edit', 'bnb_apartment'), 'edit_item' => __('Edit Apartment', 'bnb_apartment'), 'new_item' => __('New Apartment', 'bnb_apartment'), 'view' => __('View Apartment', 'bnb_apartment'), 'view_item' => __('View Apartment', 'bnb_apartment'), 'search_items' => __('Search Apartment', 'bnb_apartment'), 'not_found' => __('No Apartments found', 'bnb_apartment'), 'not_found_in_trash' => __('No Apartments found in Trash', 'bnb_apartment')), 'public' => true, 'hierarchical' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'accommodation'), 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'thumbnail'), 'can_export' => true, 'taxonomies' => array('post_tag', 'category'))); }
function gdlr_create_portfolio() { global $theme_option; if (!empty($theme_option['portfolio-slug'])) { $portfolio_slug = $theme_option['portfolio-slug']; $portfolio_category_slug = $theme_option['portfolio-category-slug']; $portfolio_tag_slug = $theme_option['portfolio-tag-slug']; } else { $portfolio_slug = 'portfolio'; $portfolio_category_slug = 'portfolio_category'; $portfolio_tag_slug = 'portfolio_tag'; } register_post_type('portfolio', array('labels' => array('name' => __('Portfolios', 'gdlr-portfolio'), 'singular_name' => __('Portfolio', 'gdlr-portfolio'), 'add_new' => __('Add New', 'gdlr-portfolio'), 'add_new_item' => __('Add New Portfolio', 'gdlr-portfolio'), 'edit_item' => __('Edit Portfolio', 'gdlr-portfolio'), 'new_item' => __('New Portfolio', 'gdlr-portfolio'), 'all_items' => __('All Portfolios', 'gdlr-portfolio'), 'view_item' => __('View Portfolio', 'gdlr-portfolio'), 'search_items' => __('Search Portfolio', 'gdlr-portfolio'), 'not_found' => __('No portfolios found', 'gdlr-portfolio'), 'not_found_in_trash' => __('No portfolios found in Trash', 'gdlr-portfolio'), 'parent_item_colon' => '', 'menu_name' => __('Portfolios', 'gdlr-portfolio')), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug' => $portfolio_slug), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 5, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields'))); // create portfolio categories register_taxonomy('portfolio_category', array("portfolio"), array('hierarchical' => true, 'show_admin_column' => true, 'label' => __('Portfolio Categories', 'gdlr-portfolio'), 'singular_label' => __('Portfolio Category', 'gdlr-portfolio'), 'rewrite' => array('slug' => $portfolio_category_slug))); register_taxonomy_for_object_type('portfolio_category', 'portfolio'); // create portfolio tag register_taxonomy('portfolio_tag', array('portfolio'), array('hierarchical' => false, 'show_admin_column' => true, 'label' => __('Portfolio Tags', 'gdlr-portfolio'), 'singular_label' => __('Portfolio Tag', 'gdlr-portfolio'), 'rewrite' => array('slug' => $portfolio_tag_slug))); register_taxonomy_for_object_type('portfolio_tag', 'portfolio'); // add filter to style single template if (defined('WP_THEME_KEY') && WP_THEME_KEY == 'goodlayers') { if (!empty($theme_option['portfolio-page-style']) && $theme_option['portfolio-page-style'] == 'blog-style') { add_filter('single_template', 'gdlr_register_portfolio_blog_template'); } else { add_filter('single_template', 'gdlr_register_portfolio_template'); } } }
function myplugin_settings() { // Add tag metabox to page register_taxonomy_for_object_type('post_tag', 'page'); // Add category metabox to page register_taxonomy_for_object_type('category', 'page'); }
public function add_taxonomy($name, $plural, $args = array(), $labels = array()) { if (!empty($name) && !empty($plural)) { // We need to need to know the post type name so we can attach the taxonomy to it $post_type_name = $this->post_type_name; // Taxonomy properties $taxonomy_name = self::uglify($name); $tax_plural = self::uglify($plural); $taxonomy_args = $args; $taxonomy_labels = $labels; if (!taxonomy_exists($taxonomy_name)) { /* Create taxonomy and attach it to the object type (post type) */ // Capitalize words and it plural $name = self::beautify($name); $plural = self::beautify($plural); // Default labels, overwrite them with the given labels $labels = array_merge(array('name' => $plural, 'singular_name' => $name, 'search_items' => 'Search ' . $plural, 'all_items' => 'All ' . $plural, 'parent_item' => 'Parent ' . $name, 'parent_item_colon' => 'Parent ' . $name . ':', 'edit_item' => 'Edit ' . $name, 'update_item' => 'Update ' . $name, 'add_new_item' => 'Add New ' . $name, 'new_item_name' => 'New ' . $name . ' Name', 'menu_name' => $name), $taxonomy_labels); // Default args, overwrite them with the given labels $args = array_merge(array('labels' => $labels, 'hierarchical' => true, 'query_var' => true, 'rewrite' => true), $taxonomy_args); // Registers taxonomy add_action('init', function () use($taxonomy_name, $post_type_name, $args) { register_taxonomy($taxonomy_name, $post_type_name, $args); }); } else { /* The taxonomy already exists. We are going to attach the existing taxonomy to the object type (post type) */ add_action('init', function () use($taxonomy_name, $post_type_name) { register_taxonomy_for_object_type($taxonomy_name, $post_type_name); }); } } }
/** * Registers Attachment Categories and Attachment Tags custom taxonomies, adds taxonomy-related filters * * @since 0.1 * * @return void */ private static function _build_taxonomies() { if (MLAOptions::mla_taxonomy_support('attachment_category')) { $labels = array('name' => _x('Att. Categories', 'taxonomy general name'), 'singular_name' => _x('Att. Category', 'taxonomy singular name'), 'search_items' => __('Search Att. Categories'), 'all_items' => __('All Att. Categories'), 'parent_item' => __('Parent Att. Category'), 'parent_item_colon' => __('Parent Att. Category:'), 'edit_item' => __('Edit Att. Category'), 'update_item' => __('Update Att. Category'), 'add_new_item' => __('Add New Att. Category'), 'new_item_name' => __('New Att. Category Name'), 'menu_name' => __('Att. Category')); register_taxonomy('attachment_category', array('attachment'), array('hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'query_var' => true, 'rewrite' => true)); } if (MLAOptions::mla_taxonomy_support('attachment_tag')) { $labels = array('name' => _x('Att. Tags', 'taxonomy general name'), 'singular_name' => _x('Att. Tag', 'taxonomy singular name'), 'search_items' => __('Search Att. Tags'), 'all_items' => __('All Att. Tags'), 'parent_item' => __('Parent Att. Tag'), 'parent_item_colon' => __('Parent Att. Tag:'), 'edit_item' => __('Edit Att. Tag'), 'update_item' => __('Update Att. Tag'), 'add_new_item' => __('Add New Att. Tag'), 'new_item_name' => __('New Att. Tag Name'), 'menu_name' => __('Att. Tag')); register_taxonomy('attachment_tag', array('attachment'), array('hierarchical' => false, 'labels' => $labels, 'show_ui' => true, 'update_count_callback' => '_update_post_term_count', 'query_var' => true, 'rewrite' => true)); } $taxonomies = get_taxonomies(array('show_ui' => true), 'names'); foreach ($taxonomies as $tax_name) { if (MLAOptions::mla_taxonomy_support($tax_name)) { register_taxonomy_for_object_type($tax_name, 'attachment'); if ('checked' == MLAOptions::mla_get_option('attachments_column')) { add_filter("manage_edit-{$tax_name}_columns", 'MLAObjects::mla_taxonomy_get_columns_filter', 10, 1); // $columns add_filter("manage_{$tax_name}_custom_column", 'MLAObjects::mla_taxonomy_column_filter', 10, 3); // $place_holder, $column_name, $tag->term_id } // option is checked } // taxonomy support } // foreach }
public function register_taxonomies() { parent::register_taxonomies(); foreach (get_object_taxonomies('wp-parser-function') as $taxonomy) { register_taxonomy_for_object_type($taxonomy, 'wp-parser-constant'); } }
function gdlr_soccer_create_fixtures_results() { register_post_type('fixture_and_result', array('labels' => array('name' => __('Fixtures & Results', 'gdlr-soccer'), 'singular_name' => __('Fixture & Result', 'gdlr-soccer'), 'add_new' => __('Add New', 'gdlr-soccer'), 'add_new_item' => __('Add New fixture & result', 'gdlr-soccer'), 'edit_item' => __('Edit fixture & result', 'gdlr-soccer'), 'new_item' => __('New fixture & result', 'gdlr-soccer'), 'all_items' => __('All fixtures & results', 'gdlr-soccer'), 'view_item' => __('View fixture & result', 'gdlr-soccer'), 'search_items' => __('Search fixtures & results', 'gdlr-soccer'), 'not_found' => __('No fixtures & results found', 'gdlr-soccer'), 'not_found_in_trash' => __('No fixtures & results found in Trash', 'gdlr-soccer'), 'parent_item_colon' => '', 'menu_name' => __('Fixtures & Results', 'gdlr-soccer')), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 5, 'supports' => array('title', 'author', 'thumbnail', 'custom-fields'))); register_taxonomy('result_category', array("fixture_and_result"), array('hierarchical' => true, 'show_admin_column' => true, 'label' => __('Result Categories', 'gdlr-soccer'), 'singular_label' => __('Result Category', 'gdlr-soccer'), 'rewrite' => array('slug' => 'result_category'))); register_taxonomy_for_object_type('result_category', 'fixture_and_result'); add_filter('single_template', 'gdlr_soccer_register_fixture_result_template'); }
function gdlr_conference_create_session() { register_post_type('session', array('labels' => array('name' => __('Sessions', 'gdlr-conference'), 'singular_name' => __('Session', 'gdlr-conference'), 'add_new' => __('Add New', 'gdlr-conference'), 'add_new_item' => __('Add New session', 'gdlr-conference'), 'edit_item' => __('Edit session', 'gdlr-conference'), 'new_item' => __('New session', 'gdlr-conference'), 'all_items' => __('All sessions', 'gdlr-conference'), 'view_item' => __('View session', 'gdlr-conference'), 'search_items' => __('Search sessions', 'gdlr-conference'), 'not_found' => __('No sessions found', 'gdlr-conference'), 'not_found_in_trash' => __('No sessions found in Trash', 'gdlr-conference'), 'parent_item_colon' => '', 'menu_name' => __('Sessions', 'gdlr-conference')), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 5, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields'))); register_taxonomy('session_category', array("session"), array('hierarchical' => true, 'show_admin_column' => true, 'label' => __('Session Categories', 'gdlr-conference'), 'singular_label' => __('Session Category', 'gdlr-conference'), 'rewrite' => array('slug' => 'session_category'))); register_taxonomy_for_object_type('session_category', 'session'); add_filter('single_template', 'gdlr_conference_register_session_template'); }
public static function create_post_type_new_developments() { register_taxonomy_for_object_type('category', 'new-developments'); // Register Taxonomies for Category register_taxonomy_for_object_type('post_tag', 'new-developments'); register_post_type('new-developments', array('labels' => array('name' => __('New Developments', 'new-development'), 'singular_name' => __('New Developments', 'new-development'), 'add_new' => __('Add New', 'new-development'), 'add_new_item' => __('Add New New Developments', 'new-development'), 'edit' => __('Edit', 'new-development'), 'edit_item' => __('Edit New Development', 'new-development'), 'new_item' => __('New New Developments', 'new-development'), 'view' => __('View New Developments', 'new-development'), 'view_item' => __('View New Development', 'new-development'), 'search_items' => __('Search New Developments', 'new-development'), 'not_found' => __('No New Developments found', 'new-development'), 'not_found_in_trash' => __('No New Developments found in Trash', 'new-development')), 'public' => true, 'hierarchical' => true, 'has_archive' => true, 'supports' => array('title', 'editor', 'excerpt', 'thumbnail'), 'can_export' => true, 'taxonomies' => array('post_tag', 'category'))); }
function create_post_type_html5() { register_taxonomy_for_object_type('category', 'html5-blank'); // Register Taxonomies for Category register_taxonomy_for_object_type('post_tag', 'html5-blank'); register_post_type('html5-blank', array('labels' => array('name' => __('HTML5 Blank Custom Post', 'titeblog'), 'singular_name' => __('HTML5 Blank Custom Post', 'titeblog'), 'add_new' => __('Add New', 'titeblog'), 'add_new_item' => __('Add New HTML5 Blank Custom Post', 'titeblog'), 'edit' => __('Edit', 'titeblog'), 'edit_item' => __('Edit HTML5 Blank Custom Post', 'titeblog'), 'new_item' => __('New HTML5 Blank Custom Post', 'titeblog'), 'view' => __('View HTML5 Blank Custom Post', 'titeblog'), 'view_item' => __('View HTML5 Blank Custom Post', 'titeblog'), 'search_items' => __('Search HTML5 Blank Custom Post', 'titeblog'), 'not_found' => __('No HTML5 Blank Custom Posts found', 'titeblog'), 'not_found_in_trash' => __('No HTML5 Blank Custom Posts found in Trash', 'titeblog')), 'public' => true, 'hierarchical' => true, 'has_archive' => true, 'supports' => array('title', 'editor', 'excerpt', 'thumbnail'), 'can_export' => true, 'taxonomies' => array('post_tag', 'category'))); }
public function add_taxonomy($name, $args = array(), $labels = array()) { if (!empty($name)) { // We need to know the post type name, so the new taxonomy can be attached to it. $post_type_name = $this->post_type_name; // Taxonomy properties $taxonomy_name = strtolower(str_replace(' ', '_', $name)); $taxonomy_labels = $labels; $taxonomy_args = $args; if (!taxonomy_exists($taxonomy_name)) { //Capitilize the words and make it plural $name = ucwords(str_replace('_', ' ', $name)); $plural = $name . 's'; // Default labels, overwrite them with the given labels. $labels = array_merge(array('name' => _x($plural, 'taxonomy general name'), 'singular_name' => _x($name, 'taxonomy singular name'), 'search_items' => __('Search ' . $plural), 'all_items' => __('All ' . $plural), 'parent_item' => __('Parent ' . $name), 'parent_item_colon' => __('Parent ' . $name . ':'), 'edit_item' => __('Edit ' . $name), 'update_item' => __('Update ' . $name), 'add_new_item' => __('Add New ' . $name), 'new_item_name' => __('New ' . $name . ' Name'), 'menu_name' => __($name)), $taxonomy_labels); // Default arguments, overwitten with the given arguments $args = array_merge(array('label' => $plural, 'labels' => $labels, 'public' => true, 'show_ui' => true, 'show_in_nav_menus' => true, '_builtin' => false), $taxonomy_args); // Add the taxonomy to the post type add_action('init', function () use($taxonomy_name, $post_type_name, $args) { register_taxonomy($taxonomy_name, $post_type_name, $args); }); } else { add_action('init', function () use($taxonomy_name, $post_type_name) { register_taxonomy_for_object_type($taxonomy_name, $post_type_name); }); } } }
function eac_easy_classes_init() { load_plugin_textdomain('easyclasses', false, basename(dirname(__FILE__)) . '/languages/'); // EASY CLASS POST TYPE // register_post_type('easyclass', array('label' => __('Classes', 'easyclasses'), 'singular_label' => __('Class', 'easyclasses'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'), 'menu_icon' => plugins_url('images/classes.png', __FILE__))); // SUBJECT CATEGORY // register_taxonomy('subject', 'easyclass', array('hierarchical' => true, 'label' => __('Subject', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // LEVEL TAG // register_taxonomy('level', 'easyclass', array('hierarchical' => true, 'label' => __('Level', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // TEACHER CATEGORY // register_taxonomy('teacher', 'easyclass', array('hierarchical' => true, 'label' => __('Teacher', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // DAY CATEGORY // register_taxonomy('day', 'easyclass', array('hierarchical' => true, 'label' => __('Day', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // BEGINNING HOUR CATEGORY // register_taxonomy('beginning', 'easyclass', array('hierarchical' => true, 'label' => __('Starting time', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // ENDING HOUR CATEGORY // register_taxonomy('ending', 'easyclass', array('hierarchical' => true, 'label' => __('Ending time', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // PLACE CATEGORY // register_taxonomy('place', 'easyclass', array('hierarchical' => true, 'label' => __('Place', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // ROOM CATEGORY // register_taxonomy('room', 'easyclass', array('hierarchical' => true, 'label' => __('Room', 'easyclasses'), 'query_var' => true, 'rewrite' => false)); // TEACHER POST TYPE // register_post_type('teachers', array('label' => __('Teachers', 'easyclasses'), 'singular_label' => __('Teacher', 'easyclasses'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'comments'), 'menu_icon' => plugins_url('images/teachers.png', __FILE__))); // LINKING TEACHER TAG TO TEACHERS // register_taxonomy_for_object_type('teacher', 'teachers'); }
/** * Handle builtin taxonomies * * Function add or remove taxonomy to post type * * @since 1.9.0 * * @param string $taxonomy taxonomy slug/name * @param array $data taxonomy configuration * */ function wpcf_taxonomies_register($taxonomy, $data) { // check which types are supported if (isset($data['supports']) && is_array($data['supports'])) { if (!empty($data['supports'])) { foreach (array_keys($data['supports']) as $post_type) { register_taxonomy_for_object_type($taxonomy, $post_type); } } // check for inbuilt Tags (post_tag) and Categories if post is not supported, // so it needs to get unregistered if (($data['slug'] == 'post_tag' || $data['slug'] == 'category') && !array_key_exists('post', $data['supports'])) { unregister_taxonomy_for_object_type($taxonomy, 'post'); } } // this is only left for backwards compatibility if (isset($data['disabled_post_types']) && is_array($data['disabled_post_types'])) { foreach (array_keys($data['disabled_post_types']) as $post_type) { unregister_taxonomy_for_object_type($taxonomy, $post_type); } } // unregister if (isset($data['disabled']) && $data['disabled']) { register_taxonomy($data['slug'], array()); // hide } else { if (isset($data['public']) && strval($data['public']) == 'hidden') { global $wp_taxonomies; $wp_taxonomies[$data['slug']]->public = false; $wp_taxonomies[$data['slug']]->show_ui = false; $wp_taxonomies[$data['slug']]->show_in_menu = false; } } }
function gdlr_create_hostel_room() { global $theme_option; if (!empty($theme_option['hostel-room-slug'])) { $room_slug = $theme_option['hostel-room-slug']; $room_category_slug = $theme_option['hostel-room-category-slug']; $room_tag_slug = $theme_option['hostel-room-tag-slug']; } else { $room_slug = 'hostel_room'; $room_category_slug = 'hostel_room_category'; $room_tag_slug = 'hostel_room_tag'; } register_post_type('hostel_room', array('labels' => array('name' => __('Rooms', 'gdlr-hotel'), 'singular_name' => __('Room', 'gdlr-hotel'), 'add_new' => __('Add New', 'gdlr-hotel'), 'add_new_item' => __('Add New Room', 'gdlr-hotel'), 'edit_item' => __('Edit Room', 'gdlr-hotel'), 'new_item' => __('New Room', 'gdlr-hotel'), 'all_items' => __('All Rooms', 'gdlr-hotel'), 'view_item' => __('View Room', 'gdlr-hotel'), 'search_items' => __('Search Room', 'gdlr-hotel'), 'not_found' => __('No rooms found', 'gdlr-hotel'), 'not_found_in_trash' => __('No rooms found in Trash', 'gdlr-hotel'), 'parent_item_colon' => '', 'menu_name' => __('Rooms (Hostel)', 'gdlr-hotel')), 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array('slug' => $room_slug), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 8, 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments', 'custom-fields'))); // create room categories register_taxonomy('hostel_room_category', array("hostel_room"), array('hierarchical' => true, 'show_admin_column' => true, 'label' => __('Room Categories', 'gdlr-hotel'), 'singular_label' => __('Room Category', 'gdlr-hotel'), 'rewrite' => array('slug' => $room_category_slug))); register_taxonomy_for_object_type('hostel_room_category', 'hostel_room'); // create custom taxonomy for room category if (is_admin() && class_exists('gdlr_tax_meta')) { global $gdlr_sidebar_controller; new gdlr_tax_meta(array('taxonomy' => 'hostel_room_category', 'slug' => 'gdlr_hostel_branch'), array('upload' => array('title' => __('Hostel Thumbnail', 'gdlr-song'), 'type' => 'upload'), 'content' => array('title' => __('Hostel Location', 'gdlr-song'), 'type' => 'textarea'))); } // create room tag register_taxonomy('hostel_room_tag', array('hostel_room'), array('hierarchical' => false, 'show_admin_column' => true, 'label' => __('Room Tags', 'gdlr-hotel'), 'singular_label' => __('Room Tag', 'gdlr-hotel'), 'rewrite' => array('slug' => $room_tag_slug))); register_taxonomy_for_object_type('hostel_room_tag', 'hostel_room'); // add filter to style single template add_filter('single_template', 'gdlr_register_hostel_room_template'); }
/** * Register doc_category taxonomy */ function docu_setup_taxonomies() { $category_labels = array('name' => sprintf(_x('%s Categories', 'taxonomy general name', 'docu'), docu_get_label_singular()), 'singular_name' => _x('Category', 'taxonomy singular name', 'docu'), 'search_items' => __('Search Categories', 'docu'), 'all_items' => __('All Categories', 'docu'), 'parent_item' => __('Parent Category', 'docu'), 'parent_item_colon' => __('Parent Category:', 'docu'), 'edit_item' => __('Edit Category', 'docu'), 'update_item' => __('Update Category', 'docu'), 'add_new_item' => sprintf(__('Add New %s Category', 'docu'), docu_get_label_singular()), 'new_item_name' => __('New Category Name', 'docu'), 'menu_name' => __('Categories', 'docu')); $category_args = array('hierarchical' => true, 'labels' => apply_filters('docu_doc_category_labels', $category_labels), 'show_ui' => true, 'query_var' => 'doc_category', 'rewrite' => array('slug' => 'docs' . '/category', 'with_front' => false, 'hierarchical' => true), 'show_admin_column' => true); register_taxonomy('doc_category', array('doc'), apply_filters('docu_doc_category_args', $category_args)); register_taxonomy_for_object_type('doc_category', 'doc'); }