• I have a custom taxonomy that isn’t showing up on what I think to be the correct template. Here’s the function:

    add_action( 'init', 'blogtags' );
    
            function blogtags() {
                $args1 = array(
                    'hierarchical' => false,
                    'label' => 'Blog Tags',
                    'show_admin_column' => true,
                    'rewrite' => array( 'slug' => 'blogtags' ),
                    'add_new_item' => 'Add New Tag',
                );
            register_taxonomy( 'blogtags', array( 'azblog' ), $args1 );
    }

    Now shouldn’t the template page be taxonomy-blogtags.php? I have another custom taxonomy using the exact same function only instead of the name blogtags, it’s blogsubjects. That one DOES work with taxonomy-blogsubjects.php.

    I’m confused!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Hi harshclimate,

    I think you may just need to visit the permalinks settings screen so WP can setup rewrite rules for your taxonomy. No need to do anything but visit, it happens automatically once you load the screen.

    Thread Starter harshclimate

    (@harshclimate)

    That did it! I thought I had tried that already but I guess I didn’t. I wonder why you have to do that? Is that a bug?

    Moderator bcworkz

    (@bcworkz)

    I’d call it a quirk, not a bug. Regenerating rewrite rules is computationally very expensive. WP cannot automatically do this every time the code is loaded. Somehow we need to trigger the process only as needed. Plugins in the repository that introduce custom objects are required to execute flush_rewrite_rules() from an activation hook callback. For code development on our own sites, visiting permalinks is an easy alternative to writing the necessary code to do so.

    Just don’t make the mistake some people do where they call flush_rewrite_rules() from code that executes on every single request. It’s a good way to get a warning from your host that your site is consuming too much resource.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Taxonomy – Page not found help!’ is closed to new replies.