• I developed a plugin that calls different Custom Posts. It works great: I see the options in the dashboard, I can add new articles and I can find the list of articles on the url ‘personajes’ , but when I try to call a list of taxonomy, tells me that finds nothing… What can be ? Here is the code. Please help ??

    <?php 
    
    // Register Custom Post Type
    function personajes_post_type() {
    
    	$labels = array(
    		'name'                => _x( 'personajes', 'Post Type General Name', 'text_domain' ),
    		'singular_name'       => _x( 'personaje', 'Post Type Singular Name', 'text_domain' ),
    		'menu_name'           => __( 'Personajes', 'text_domain' ),
    		'name_admin_bar'      => __( 'Post Type', 'text_domain' ),
    		'parent_item_colon'   => __( 'Superior:', 'text_domain' ),
    		'all_items'           => __( 'Todos', 'text_domain' ),
    		'add_new_item'        => __( 'Agregar personaje', 'text_domain' ),
    		'add_new'             => __( 'Agregar nuevo', 'text_domain' ),
    		'new_item'            => __( 'Nuevo personaje', 'text_domain' ),
    		'edit_item'           => __( 'Editar personaje', 'text_domain' ),
    		'update_item'         => __( 'Actualizar personaje', 'text_domain' ),
    		'view_item'           => __( 'Ver personaje', 'text_domain' ),
    		'search_items'        => __( 'Buscar personajes', 'text_domain' ),
    		'not_found'           => __( 'No se han encontrado resultados', 'text_domain' ),
    		'not_found_in_trash'  => __( 'No hay personajes en la papelera', 'text_domain' ),
    	);
    	$args = array(
    		'label'               => __( 'personajes', 'text_domain' ),
    		'description'         => __( 'Lista de personajes de Slam Dunk', 'text_domain' ),
    		'labels'              => $labels,
    		'supports'            => array( 'title', 'editor', 'thumbnail', ),
    		'hierarchical'        => false,
    		'public'              => true,
    		'show_ui'             => true,
    		'show_in_menu'        => true,
    		'menu_position'       => 20,
    		'show_in_admin_bar'   => true,
    		'show_in_nav_menus'   => false,
    		'can_export'          => true,
    		'has_archive'         => true,
    		'exclude_from_search' => true,
    		'publicly_queryable'  => true,
    		'capability_type'     => 'page',
    	);
    	register_post_type( 'personajes', $args );
    
    }
    
    // Hook into the 'init' action
    add_action( 'init', 'personajes_post_type', 0 );
    
    //----
    // AGREGAR UN íCONO AL CUSTOM POST TYPE PERSONAJES
    //----
    
    function slamdunk_personajes_icon() {
    ?>
    <style type="text/css" media="screen">
    #adminmenu #menu-posts-personajes .wp-menu-image::before{
    	content: "\f336";
    }
    </style>
    
    <?php
    }
    add_action('admin_head', 'slamdunk_personajes_icon');
    
    //----
    // AGREGAR CUSTOM TAXONOMY PARA PERSONAJES
    //----
    
    if ( ! function_exists( 'categorias_personaje_taxonomy' ) ) {
    
    // Register Custom Taxonomy
    function categorias_personaje_taxonomy() {
    
    	$labels = array(
    		'name'                       => _x( 'Familias de personaje', 'Taxonomy General Name', 'text_domain' ),
    		'singular_name'              => _x( 'Categoría de personaje', 'Taxonomy Singular Name', 'text_domain' ),
    		'menu_name'                  => __( 'Familias de personajes', 'text_domain' ),
    		'all_items'                  => __( 'All ItemsTodas', 'text_domain' ),
    		'parent_item'                => __( 'Superior', 'text_domain' ),
    		'parent_item_colon'          => __( 'Superior: ', 'text_domain' ),
    		'new_item_name'              => __( 'Nueva familia', 'text_domain' ),
    		'add_new_item'               => __( 'Agregar nueva familia', 'text_domain' ),
    		'edit_item'                  => __( 'Editar familia', 'text_domain' ),
    		'update_item'                => __( 'Actualizar familia', 'text_domain' ),
    		'view_item'                  => __( 'Ver familia', 'text_domain' ),
    		'separate_items_with_commas' => __( 'Separar familias con coma', 'text_domain' ),
    		'add_or_remove_items'        => __( 'Agregar o eliminar familias', 'text_domain' ),
    		'choose_from_most_used'      => __( 'Elegir entre las más usadas', 'text_domain' ),
    		'popular_items'              => __( 'Popular Items', 'text_domain' ),
    		'search_items'               => __( 'Buscar familias de personajes', 'text_domain' ),
    		'not_found'                  => __( 'No encontrado', 'text_domain' ),
    	);
    	$rewrite = array(
    		'slug'                       => 'familia_personajes',
    		'with_front'                 => true,
    		'hierarchical'               => false,
    	);
    	$args = array(
    		'labels'                     => $labels,
    		'hierarchical'               => true,
    		'public'                     => true,
    		'show_ui'                    => true,
    		'show_admin_column'          => true,
    		'show_in_nav_menus'          => true,
    		'show_tagcloud'              => false,
    		'rewrite'                    => $rewrite,
    	);
    	register_taxonomy( 'categorias_personaje', array( 'personajes' ), $args );
    
    }
    
    // Hook into the 'init' action
    add_action( 'init', 'categorias_personaje_taxonomy', 0 );
    
    }
Viewing 1 replies (of 1 total)
  • Richard

    (@richardcoffee)

    Just registering your taxonomy is not enough. You also have to link it to the custom post type, like so:

    register_taxonomy_for_object_type('categorias_personaje','personajes');

    Place this immediately after the call to register_taxonomy.

Viewing 1 replies (of 1 total)
  • The topic ‘Taxonomy problem’ is closed to new replies.