404 on single
-
Hello,
I am having trouble here. I have two CPT and only one have custom taxonomy. When I enable the the rewrite rule for the CPT with custom taxonomy and visit the page I get 404 page. The link looks just as it should but my post doesn’t show up. If I disable the rewrite rules it works just fine.
This is example of my CTP:
function create_seath_cpt_stuff () { $labels = array( 'name' => _x( 'stuff', 'Post type general name', 'seath' ), 'singular_name' => _x( 'stuff', 'Post type singular name', 'seath' ), 'menu_name' => _x( 'stuff', 'Admin Menu text', 'seath' ), 'name_admin_bar' => _x( 'stuff', 'Add New on Toolbar', 'seath' ), 'add_new' => __( 'Add New stuff', 'seath' ), 'add_new_item' => __( 'Add New stuff', 'seath' ), 'new_item' => __( 'New stuff', 'seath' ), 'edit_item' => __( 'Edit stuff', 'seath' ), 'view_item' => __( 'View stuff', 'seath' ), 'all_items' => __( 'All stuffs', 'seath' ), 'search_items' => __( 'Search stuffs', 'seath' ), 'parent_item_colon' => __( 'Parent stuff:', 'seath' ), 'not_found' => __( 'Nothing found.', 'seath' ), 'not_found_in_trash' => __( 'Nothing found in Trash.', 'seath' ), 'archives' => _x( 'stuff archives', 'seath' ), ); $args = array( 'labels' => $labels, 'description' => 'Just stuff.', 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'stuff' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => 6, 'menu_icon' => 'data:image/svg+xml;base64,' . base64_encodeff('<svg id="_x31__x2C_5" enable-background="new 0 0 24 24" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path style="fill:#fff;" d="m6.75 18c-.192 0-.384-.073-.53-.22-.293-.293-.293-.768 0-1.061l2.719-2.719-2.72-2.72c-.293-.293-.293-.768 0-1.061s.768-.293 1.061 0l3.25 3.25c.293.293.293.768 0 1.061l-3.25 3.25c-.146.147-.338.22-.53.22z"/><path style="fill:#fff;" d="m17.25 18h-4.5c-.414 0-.75-.336-.75-.75s.336-.75.75-.75h4.5c.414 0 .75.336.75.75s-.336.75-.75.75z"/><path style="fill:#fff;" d="m21.25 23h-18.5c-1.517 0-2.75-1.233-2.75-2.75v-16.5c0-1.517 1.233-2.75 2.75-2.75h18.5c1.517 0 2.75 1.233 2.75 2.75v16.5c0 1.517-1.233 2.75-2.75 2.75zm-18.5-20.5c-.689 0-1.25.561-1.25 1.25v16.5c0 .689.561 1.25 1.25 1.25h18.5c.689 0 1.25-.561 1.25-1.25v-16.5c0-.689-.561-1.25-1.25-1.25z"/><path style="fill:#fff;" d="m23.25 6h-22.5c-.414 0-.75-.336-.75-.75s.336-.75.75-.75h22.5c.414 0 .75.336.75.75s-.336.75-.75.75z"/></svg>'), 'supports' => array( 'title', 'editor' ), 'taxonomies' => array( '' ), 'show_in_rest' => true ); register_post_type('seath_stuff',$args); } add_action('init', 'create_seath_cpt_stuff', 0);And example of my taxonomy:
function register_taxonomy_for_custom_type() { register_taxonomy('seath_stuff_tags', array('seath_stuff'), array( 'labels' => array( 'name' => __( 'stuff Tag', 'taxonomy general name', 'seath' ), 'singular_name' => __( 'stuff Tag', 'taxonomy singular name', 'seath' ), 'search_items' => __( 'Search stuff Tags', 'seath' ), 'all_items' => __( 'All stuff Tags', 'seath' ), 'parent_item' => __( 'Parent stuff Tag', 'seath' ), 'parent_item_colon' => __( 'Parent stuff Tag:', 'seath' ), 'edit_item' => __( 'Edit stuff Tag', 'seath' ), 'update_item' => __( 'Update stuff Tag', 'seath' ), 'add_new_item' => __( 'Add New stuff Tag', 'seath' ), 'new_item_name' => __( 'New stuff Tag Name', 'seath' ), 'menu_name' => __( 'stuff Tags', 'seath' ), ), 'public' => true, 'hierarchical' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_rest' => false, 'show_admin_column' => true, 'rewrite' => array( 'slug' => 'stuff-category' ), 'query_var' => true, ) ); } add_action( 'init', 'register_taxonomy_for_custom_type', 0 );I have been trying to figure out if I made mistake someplace or whats going on, but I am not having any luck.
Hope you can help. Thanks.
Viewing 12 replies - 1 through 12 (of 12 total)
Viewing 12 replies - 1 through 12 (of 12 total)
The topic ‘404 on single’ is closed to new replies.