Custom Taxonomy Archive

Viewing 3 posts - 1 through 3 (of 3 total)
  • #17592
    chodgson
    Participant

    I have added to my posts a custom taxonomy called “Location”. (see below)

    The wp admin area allows me to add a link to the archive in the menu however, when you click on the link it returns a single post and not the archive.

    Can you point me in the right direction as to where I can include the generation of an archive page for the custom taxonomy.

    Code I added into theme functions:

    // Register Custom Taxonomy
    function custom_taxonomy_location() {

    $labels = array(
    ‘name’ => _x( ‘Locations’, ‘Taxonomy General Name’, ‘text_domain’ ),
    ‘singular_name’ => _x( ‘Location’, ‘Taxonomy Singular Name’, ‘text_domain’ ),
    ‘menu_name’ => __( ‘Locations’, ‘text_domain’ ),
    ‘all_items’ => __( ‘All Locations’, ‘text_domain’ ),
    ‘parent_item’ => __( ‘Parent Location’, ‘text_domain’ ),
    ‘parent_item_colon’ => __( ‘Parent Location:’, ‘text_domain’ ),
    ‘new_item_name’ => __( ‘New Location Name’, ‘text_domain’ ),
    ‘add_new_item’ => __( ‘Add New Location’, ‘text_domain’ ),
    ‘edit_item’ => __( ‘Edit Location’, ‘text_domain’ ),
    ‘update_item’ => __( ‘Update Location’, ‘text_domain’ ),
    ‘separate_items_with_commas’ => __( ‘Separate Locations with commas’, ‘text_domain’ ),
    ‘search_items’ => __( ‘Search Locations’, ‘text_domain’ ),
    ‘add_or_remove_items’ => __( ‘Add or remove Locations’, ‘text_domain’ ),
    ‘choose_from_most_used’ => __( ‘Choose from the most used Locations’, ‘text_domain’ ),
    );
    $rewrite = array(
    ‘slug’ => ‘location’,
    ‘with_front’ => true,
    ‘hierarchical’ => true,
    );
    $args = array(
    ‘labels’ => $labels,
    ‘hierarchical’ => true,
    ‘public’ => true,
    ‘show_ui’ => true,
    ‘show_admin_column’ => true,
    ‘show_in_nav_menus’ => true,
    ‘show_tagcloud’ => true,
    ‘rewrite’ => $rewrite,
    );
    register_taxonomy( ‘location’, ‘post’, $args );

    }

    // Hook into the ‘init’ action
    add_action( ‘init’, ‘custom_taxonomy_location’, 0 );

    #17599
    Daniel Tara
    Keymaster

    I believe it’s a permalink issue. Try saving your permalink structure twice and see if the issue still persists.

    #17600
    chodgson
    Participant

    Yes! It was a permalink issue. I think there was a clash of similar slugs. So it now works fine. Many thanks for pointing me in the right direction.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.