Last active
October 30, 2017 07:40
-
-
Save kirasiris/fadb4d7da341f3416944770917c6397c to your computer and use it in GitHub Desktop.
This file contains 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 characters
<?php | |
//========================= Categorias para el Portfolio Custom Post Type ===========================// | |
//Crea un custom taxonomy para los posts | |
function portfolio_categories_taxonomy() { | |
// Añade un taxonomy nuevo, y hazlo jerarquico como categorias | |
//Primero haz las traducciones necesarias para el editor visual | |
$portfolio_cats = array( | |
'name' => _x( 'Portfolio Categories', 'taxonomy general name' ), | |
'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name' ), | |
'search_items' => __( 'Search Portfolio Categories' ), | |
'all_items' => __( 'All Portfolio Categories' ), | |
'parent_item' => __( 'Parent Portfolio Category' ), | |
'parent_item_colon' => __( 'Parent Portfolio Category:' ), | |
'edit_item' => __( 'Edit Portfolio Category' ), | |
'update_item' => __( 'Update Portfolio Category' ), | |
'add_new_item' => __( 'Add New Portfolio Category' ), | |
'new_item_name' => __( 'New Portfolio Category' ), | |
'menu_name' => __( 'Portfolio Categories' ), | |
); | |
// Ahora registra la taxonomy. Remplaza el parametro 'portfolios' que esta dentro del array por el nombre de tu custom post type | |
register_taxonomy('portfolio_categories',array('portfolios'), array( | |
'hierarchical' => true, | |
'labels' => $portfolio_cats, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'portfolio categories' ), | |
)); | |
} | |
add_action( 'init', 'portfolio_categories_taxonomy', 0 ); | |
//========================= Tags para el Portfolio Custom Type ===========================// | |
//Haz un hook dentro de la accion init para llamar un taxonomy no jerarquico cuando sea utilizado. | |
function portfolio_tags_taxonomy() { | |
// Labels para el editor visual. Traducciones | |
$portfolio_tags = array( | |
'name' => _x( 'Portfolio Tags', 'taxonomy general name' ), | |
'singular_name' => _x( 'Portfolio Tag', 'taxonomy singular name' ), | |
'search_items' => __( 'Search Portfolio Tags' ), | |
'popular_items' => __( 'Popular Portfolio Tags' ), | |
'all_items' => __( 'All Portfolio Tags' ), | |
'parent_item' => null, | |
'parent_item_colon' => null, | |
'edit_item' => __( 'Edit Portfolio Tag' ), | |
'update_item' => __( 'Update Portfolio Tag' ), | |
'add_new_item' => __( 'Add New Portfolio Tag' ), | |
'new_item_name' => __( 'New Portfolio Tag Name' ), | |
'separate_items_with_commas' => __( 'Separate portfolio tags with commas' ), | |
'add_or_remove_items' => __( 'Add or remove portfolio tags' ), | |
'choose_from_most_used' => __( 'Choose from the most used portfolio tags' ), | |
'menu_name' => __( 'Portfolio Tags' ), | |
); | |
// Ahora registra el taxonomy no jerarquico como tags. | |
//Remplaza el parametro 'portfolios' que esta dentro del array por el nombre de tu custom post type | |
register_taxonomy('portfolio_tags','portfolios',array( | |
'hierarchical' => false, | |
'labels' => $portfolio_tags, | |
'show_ui' => true, | |
'show_admin_column' => true, | |
'update_count_callback' => '_update_post_term_count', | |
'query_var' => true, | |
'rewrite' => array( 'slug' => 'portfolio tags' ), | |
)); | |
} | |
add_action( 'init', 'portfolio_tags_taxonomy', 0 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment