Problema con Custom Post
-
Hola. Estoy usando la última versión de WordPress, la 3.2.1, y estaba creando un child theme del Twenty Ten donde la intención es usar los custom post como catálogo. Pero al crear el archivo functions.php me falla (adjunto el código más abajo).
Por una parte, al crear las taxonomías para los custom post aparenta dar un error y da la impresión de que no se ha creado (aunque en realidad si que lo ha hecho), lo cual es muy incómodo si la web es gestionada por terceros.
Por otra, cuando WP tiene que hacer alguna redirección, no funciona. Me explico: al Crear o editar un post me manda a una página en blanco; al igual que al intentar entrar en el panel de administración sin estar conectado o al desconectar.
El código en cuestión es este:
<?php /* CREAR CUSTOM POST TYPE "PRODUCTO" */ add_action( 'init', 'register_cpt_producto' ); function register_cpt_producto() { $labels = array( 'name' => _x( 'Producto', 'producto' ), 'singular_name' => _x( 'Producto', 'producto' ), 'add_new' => _x( 'Add New', 'producto' ), 'add_new_item' => _x( 'Add New Producto', 'producto' ), 'edit_item' => _x( 'Edit Producto', 'producto' ), 'new_item' => _x( 'New Producto', 'producto' ), 'view_item' => _x( 'View Producto', 'producto' ), 'search_items' => _x( 'Search Producto', 'producto' ), 'not_found' => _x( 'No producto found', 'producto' ), 'not_found_in_trash' => _x( 'No producto found in Trash', 'producto' ), 'parent_item_colon' => _x( 'Parent Producto:', 'producto' ), 'menu_name' => _x( 'Producto', 'producto' ), ); $args = array( 'labels' => $labels, 'hierarchical' => false, 'description' => 'Listado de productos de la tienda', /*'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ), 'taxonomies' => array( 'category', 'post_tag', 'page-category', 'autor', 'editorial' ),*/ 'supports' => array( 'title', 'editor', 'comments', 'thumbnail'), 'taxonomies' => array( 'category', 'post_tag', 'page-category', 'autor', 'editorial' ), 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'menu_position' => 5, 'menu_icon' => '', 'show_in_nav_menus' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'has_archive' => true, 'query_var' => true, 'can_export' => true, 'rewrite' => true, 'capability_type' => 'post' ); register_post_type( 'producto', $args ); } ?> <?php /* CREAR TAXONOMIA "AUTOR" */ add_action( 'init', 'register_taxonomy_autor' ); function register_taxonomy_autor() { $labels = array( 'name' => _x( 'Autores', 'autor' ), 'singular_name' => _x( 'Autor', 'autor' ), 'search_items' => _x( 'Search Autores', 'autor' ), 'popular_items' => _x( 'Popular Autores', 'autor' ), 'all_items' => _x( 'All Autores', 'autor' ), 'parent_item' => _x( 'Parent Autor', 'autor' ), 'parent_item_colon' => _x( 'Parent Autor:', 'autor' ), 'edit_item' => _x( 'Edit Autor', 'autor' ), 'update_item' => _x( 'Update Autor', 'autor' ), 'add_new_item' => _x( 'Add New Autor', 'autor' ), 'new_item_name' => _x( 'New Autor Name', 'autor' ), 'separate_items_with_commas' => _x( 'Separate autores with commas', 'autor' ), 'add_or_remove_items' => _x( 'Add or remove autores', 'autor' ), 'choose_from_most_used' => _x( 'Choose from the most used autores', 'autor' ), 'menu_name' => _x( 'Autores', 'autor' ), ); $args = array( 'labels' => $labels, 'public' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_tagcloud' => true, //'hierarchical' => false, 'hierarchical' => true, 'rewrite' => true, 'query_var' => true ); register_taxonomy( 'autor', array('producto'), $args ); } ?> <?php /* CREAR TAXONOMIA "EDITORIAL" */ add_action( 'init', 'register_taxonomy_editorial' ); function register_taxonomy_editorial() { $labels = array( 'name' => _x( 'Editoriales', 'editorial' ), 'singular_name' => _x( 'Editorial', 'editorial' ), 'search_items' => _x( 'Search Editoriales', 'editorial' ), 'popular_items' => _x( 'Popular Editoriales', 'editorial' ), 'all_items' => _x( 'All Editoriales', 'editorial' ), 'parent_item' => _x( 'Parent Editorial', 'editorial' ), 'parent_item_colon' => _x( 'Parent Editorial:', 'editorial' ), 'edit_item' => _x( 'Edit Editorial', 'editorial' ), 'update_item' => _x( 'Update Editorial', 'editorial' ), 'add_new_item' => _x( 'Add New Editorial', 'editorial' ), 'new_item_name' => _x( 'New Editorial Name', 'editorial' ), 'separate_items_with_commas' => _x( 'Separate editoriales with commas', 'editorial' ), 'add_or_remove_items' => _x( 'Add or remove editoriales', 'editorial' ), 'choose_from_most_used' => _x( 'Choose from the most used editoriales', 'editorial' ), 'menu_name' => _x( 'Editoriales', 'editorial' ), ); $args = array( 'labels' => $labels, 'public' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_tagcloud' => true, 'hierarchical' => true, 'rewrite' => true, 'query_var' => true ); register_taxonomy( 'editorial', array('producto'), $args ); } ?> <?php /* CREAR INPUT "PRECIO" */ add_action("admin_init", "admin_init"); add_action('save_post', 'save_price'); function admin_init(){ add_meta_box("prodInfo-meta", "Datos del producto", "meta_options", "producto", "side", "low"); } function meta_options(){ global $post; $custom = get_post_custom($post->ID); $price = $custom["price"][0]; ?> <label>Precio: </label><input name="price" value="<?php echo $price; ?>" /> <?php } function save_price(){ global $post; update_post_meta($post->ID, "price", $_POST["price"]); } ?>
He buscado y probado, y creo que el problema tiene que estar en la creación de las taxonomías; pero no se exactamente cual es. Si alguien pudiera ayudarme, o indicarme donde podría estar el error, estaría muy agradecido.
- El debate ‘Problema con Custom Post’ está cerrado a nuevas respuestas.