0

I created a custom post with a custom category like so

function fitters() {

    $labels = array(
        'name'                => _x( 'Fitters', 'Post Type General Name', 'text_domain' ),
        'singular_name'       => _x( 'Fitter', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'           => __( 'Fitters', 'text_domain' ),
        'parent_item_colon'   => __( 'Parent Item:', 'text_domain' ),
        'all_items'           => __( 'All Fitters', 'text_domain' ),
        'view_item'           => __( 'View Fitter', 'text_domain' ),
        'add_new_item'        => __( 'Add New Fitter', 'text_domain' ),
        'add_new'             => __( 'Add New', 'text_domain' ),
        'edit_item'           => __( 'Edit Fitter', 'text_domain' ),
        'update_item'         => __( 'Update Fitter', 'text_domain' ),
        'search_items'        => __( 'Search Fitters', 'text_domain' ),
        'not_found'           => __( 'Not found', 'text_domain' ),
        'not_found_in_trash'  => __( 'Not found in Trash', 'text_domain' ),
    );
    $args = array(
        'label'               => __( 'fitter', 'text_domain' ),
        'description'         => __( 'Post Type Description', 'text_domain' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'thumbnail', ),
        'taxonomies'          => array( 'fitter_categories', 'post_tag' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'can_export'          => true,
        'has_archive'         => true,
        'exclude_from_search' => false,
        'publicly_queryable'  => true,
        'capability_type'     => 'page',
        'menu_icon'           => 'dashicons-businessman',
    );
    register_post_type( 'fitter', $args );

}

function fitter_taxonomy() {
    register_taxonomy(
        'fitter_categories',  //The name of the taxonomy. Name should be in slug form (must not contain capital letters or spaces).
        'fitter',            //post type name
        array(
            'hierarchical'      => true,
            'label'             => 'Fitter States',  //Display name
            'query_var'         => true,
            'rewrite'           => array(
                    'slug'          => 'fitter', // This controls the base slug that will display before each term
                    'with_front'    => false // Don't display the category base before
                    )
            )
        );
}
add_action( 'init', 'fitter_taxonomy');

When I try to view the archive for just that category I get a 404 error. Anyone know why?

So when I go to mysite.com/fitter it will list all the posts. If I try to go to mysite.com/fitter/category-name I get a 404 error

1 Answer 1

0

You can copy / paste archives.php and rename it archives-your_custom_post_slug.php this can help your thème to retrieve your custom tax.

2
  • I already have a archive-fitter.php file that works to pull all the posts. It just not finding the category if you try to sort them
    – Packy
    Commented Sep 26, 2014 at 17:27
  • Did you try to set 'with_front' to true ?
    – Benoti
    Commented Sep 27, 2014 at 8:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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