I'm trying to get the archive page of some custom taxonomy. lets call this custom taxonomy "test". I've create a "taxonomy-test.php" file, but if I've try to go to "www.domain/taxonomy-test" - I'm getting 404 error page.
If I'm going to "www.domain/taxonomy-test/sub-test" - I'm getting the data from the "taxonomy-test.php" file for the specific "sub-test" in the URL.
But what I'm trying to do is to show on the test archive page ("www.domain/taxonomy-test") some links to the popular sub-tests...
from what I've read, WP don't "understand" to which tax we trying to go, so we get 404 error page.
I didn't find any solutions to that problem rater then do some redirection. did I miss something? what is the right way to solve it, and get the archive page of "test" taxonomy?
Make sure you flush the permalink from Settings -> Permalink. I try with the below code and it's working normally.
// Register Taxonomy Test
function create_test_tax() {
$labels = array(
'name' => _x( 'Test', 'taxonomy general name', 'textdomain' ),
'singular_name' => _x( 'Test', 'taxonomy singular name', 'textdomain' ),
'search_items' => __( 'Search Test', 'textdomain' ),
'all_items' => __( 'All Test', 'textdomain' ),
'parent_item' => __( 'Parent Test', 'textdomain' ),
'parent_item_colon' => __( 'Parent Test:', 'textdomain' ),
'edit_item' => __( 'Edit Test', 'textdomain' ),
'update_item' => __( 'Update Test', 'textdomain' ),
'add_new_item' => __( 'Add New Test', 'textdomain' ),
'new_item_name' => __( 'New Test Name', 'textdomain' ),
'menu_name' => __( 'Test', 'textdomain' ),
);
$args = array(
'labels' => $labels,
'description' => __( '', 'textdomain' ),
'hierarchical' => true,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'show_in_quick_edit' => true,
'show_admin_column' => true,
'show_in_rest' => true,
);
register_taxonomy( 'test', array('post'), $args );
}
add_action( 'init', 'create_test_tax' );
I also created taxonomy-test.php
root on the theme and it's working properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.