1

It works, the tags are displayed in the loop, But when entering one of the tags appears the error 404 I have also created a template tag-pizza.php

Here code of the tags

add_action( 'init', 'create_tag_taxonomies', 0 );
function create_tag_taxonomies() 
{
  // Add new taxonomy, NOT hierarchical (like tags)
  $labels = array(
    'name' => _x( 'Tags', 'taxonomy general name' ),
    'singular_name' => _x( 'Tag', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Tags' ),
    'popular_items' => __( 'Popular Tags' ),
    'all_items' => __( 'All Tags' ),
    'parent_item' => null,
    'parent_item_colon' => null,
    'edit_item' => __( 'Edit Tag' ), 
    'update_item' => __( 'Update Tag' ),
    'add_new_item' => __( 'Add New Tag' ),
    'new_item_name' => __( 'New Tag Name' ),
    'separate_items_with_commas' => __( 'Separate tags with commas' ),
    'add_or_remove_items' => __( 'Add or remove tags' ),
    'choose_from_most_used' => __( 'Choose from the most used tags' ),
    'menu_name' => __( 'Tags' ),
  ); 

  register_taxonomy('tag','pizza',array(
    'hierarchical' => false,
    'labels' => $labels,
    'show_ui' => true,
    'update_count_callback' => '_update_post_term_count',
    'query_var' => true,
    'rewrite' => array( 'slug' => 'tag' ),
     'with_front'    => true
  ));

}

here code of taxonomy principal

function my_taxonomies_productpizza() {
  $labels = array(
    'name'              => _x( 'Generos', 'taxonomy general name' ),
    'singular_name'     => _x( 'Generos', 'taxonomy singular name' ),
    'search_items'      => __( 'Search Product Categories' ),
    'all_items'         => __( 'All Product Categories' ),
    'parent_item'       => __( 'Parent Product Category' ),
    'parent_item_colon' => __( 'Parent Product Category:' ),
    'edit_item'         => __( 'Edit Product Category' ),
    'update_item'       => __( 'Update Product Category' ),
    'add_new_item'      => __( 'Add New Product Category' ),
    'new_item_name'     => __( 'New Product Category' ),
    'menu_name'         => __( 'Generos' ),
  );
  $args = array(
    'labels' => $labels,
    'hierarchical'  => true,
    'public'    => true,
    'query_var'   => 'generos',
    //slug prodotto deve coincidere con il primo parametro dello slug del Custom Post Type correlato
    'rewrite'   =>  array('slug' => 'pizza' ),
    '_builtin'    => false,
  );
  register_taxonomy( 'generos', 'pizza', $args );
}
add_action( 'init', 'my_taxonomies_productpizza', 0 );
  • The built in post_tag taxonomy already uses the URL /tag/ by default. Have you inspected the query and verified that it is for the correct taxonomy? – Milo Apr 17 '17 at 15:19
1

Try resetting permalink.

Go to Settings -> Permalinks and hit save on that page.

Try if tags are working now.

  • Not working, had tried it too – Max Apr 9 '17 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.