• Hey there,

    I have the Archive Pages option enabled and I’ve re-saved my permalinks, but for some reason all of my custom taxonomy pages create a 404 error. All other archive pages (like tags) work ok, just not custom taxonomies. Is there a setting I’m missing by any chance?

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi @ahni,

    Can you tell me how are you creating those custom taxonomies? And are you using the base removal?

    Regards
    Marqas

    Thread Starter Ahni

    (@ahni)

    Hi @marqas,

    Thanks for getting back so quick! I’m not sure what you mean by the base removal, but here’s the function I’m using for the taxonomy:

    
    add_action( 'init', 'create_taxonomies', 0 );
    function create_taxonomies() {
    $args = array(
    		'hierarchical'          => false,
    		'show_ui'               => true,
    		'show_admin_column'     => true,
    		'update_count_callback' => '_update_post_term_count',
     'query_var' => true,
    'rewrite' => array( 
                'slug' => 'indigenous-peoples',
                'with_front' => true,),
    		'public' => true,
    		'show_ui' => true,
    		'show_in_nav_menus' =>true,);
    register_taxonomy( 'peoples', 'post', $args );}
    

    I don’t know my way around code all that well, but I think it has something to do with the fact that I’m rewriting the slug?

    Thread Starter Ahni

    (@ahni)

    Hey,

    I think I just figured it out using this function to rewrite the custom taxonomy slug:

    function add_custom_rewrite_rule() {
    
        // First, try to load up the rewrite rules. We do this just in case
        // the default permalink structure is being used.
        if( ($current_rules = get_option('rewrite_rules')) ) {
    
            // Next, iterate through each custom rule adding a new rule
            // that replaces 'movies' with 'films' and give it a higher
            // priority than the existing rule.
            foreach($current_rules as $key => $val) {
                if(strpos($key, 'peoples') !== false) {
                    add_rewrite_rule(str_ireplace('peoples', 'indigenous-peoples', $key), $val, 'top');   
                } // end if
            } // end foreach
    
        } // end if/else
    
        // ...and we flush the rules
        flush_rewrite_rules();
    
    } // end add_custom_rewrite_rule
    
    add_action('init', 'add_custom_rewrite_rule');

    I tested it on a development version of the site and it worked perfectly.

    Hi @ahni,

    Please try using this: https://ampforwp.com/amp-category-base-remove-support/

    If that’s also not working then contact us at [email protected]

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom taxonomy pages don’t work’ is closed to new replies.