pages get 404 but not the taxonomy page or home page
-
The code works like it should but the problem is that is breaks normal pages and gives med 404.php instead. Help please :/
home page [Works]: https://www.text.com/
taxonomy page [Works]:https://www.text.com/category/title
Normal pages [Error 404]:https://www.text.com/contactfunction protocols_init() { $protocolsargs = array( 'label' => 'label here', 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'query_var' => true, 'menu_icon' => 'dashicons-admin-page', 'menu_position' => 5, 'has_archive' => true, 'taxonomies' => array('primary', 'status'), 'rewrite' => array('slug' => '%primary%'), 'supports' => array('title','editor','author','thumbnail'), ); register_post_type('protocols', $protocolsargs ); } add_action( 'init', 'protocols_init', 0 ); function create_protocol_taxonomies() { $primarylabels = array( 'name' => _x( 'Categorys', 'taxonomy general name' ), 'singular_name' => _x( 'Categorys', 'taxonomy singular name' ), 'search_items' => __( 'Search Categorys' ), 'all_items' => __( 'All Categorys' ), 'menu_name' => __( 'Categorys' ), ); $primaryargs = array( 'hierarchical' => true, 'labels' => $primarylabels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array('slug' => 'primary', 'with_front' => true) ); register_taxonomy( 'primary', 'protocols', $primaryargs ); // Add new taxonomy $statuslabels = array( 'name' => _x( 'Status', 'taxonomy general name' ), 'singular_name' => _x( 'Status', 'taxonomy singular name' ), 'search_items' => __( 'Search Status' ), 'all_items' => __( 'All Status' ), 'menu_name' => __( 'Status' ), 'label' => __('Status') ); $statusargs = array( 'hierarchical' => true, 'labels' => $statuslabels, 'show_ui' => true, 'show_admin_column' => TRUE, 'query_var' => 'status', 'rewrite' => array( 'slug' => 'status' ) ); register_taxonomy( 'status', 'protocols', $statusargs ); flush_rewrite_rules(); } add_action( 'init', 'create_protocol_taxonomies', 0 ); add_filter('post_link', 'primary_permalink', 10, 3); add_filter('post_type_link', 'primary_permalink', 10, 3); function primary_permalink($permalink, $post_id, $leavename) { if (strpos($permalink, '%primary%') === FALSE) return $permalink; // Get post $post = get_post($post_id); if (!$post) return $permalink; // Get taxonomy terms $terms = wp_get_object_terms($post->ID, 'primary'); if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug; else $taxonomy_slug = 'not-rated'; return str_replace('%primary%', $taxonomy_slug, $permalink); }
- The topic ‘pages get 404 but not the taxonomy page or home page’ is closed to new replies.