• I’m having a small issue with category pages for a custom taxonomy when custom permalinks are used, and I was wondering if someone might be able to help out and point out where I’m going wrong.

    I’ve created a taxonomy “Brands” for use with a custom post type (in this case, Products), using the code below place in the functions.php file of the theme. I’ve created a page template for the Brands page, which lists all the brands using the wp_list_categories($args) template tag, and that’s all fine.

    Now, if I use WordPress’ default permalink settings (where you get urls ending with ?page_id=7 and similar), clicking on any of those brands in the list, takes you to a category page which lists all the products for that brand – which is exactly the intent. If however, I set any other custom permalink structure (say /xyz/%postname%/ ), when you click on the brand name I get the 404 page instead of the category page (the same also happens when clicking view on a Brand when viewing the list within the WordPress admin).

    I’ve checked various guides on making custom taxonomies, and have tried to be very careful with setting the rewrite for the taxonomy, and now I’m at a loss as to what the issue is. Any help will be much appreciated.

    add_action( 'init', 'build_taxonomies', 0 );
    
    function build_taxonomies() {  
    
    register_taxonomy(
        'brand',
        'products',
        array(
        'labels' => array(
            'name' => 'Brands',
            'singular_name' => 'Brand',
            'search_items' => 'Search Brands',
            'popular_items' => 'Popular Brands',
            'all_items' => 'All Brands',
            'parent_item' => 'Parent Brand',
            'parent_item_colon' => 'Parent Brand:',
            'edit_item' => 'Edit Brand',
            'update_item' => 'Update Brand',
            'add_new_item' => 'Add New Brand',
            'new_item_name' => 'New Brand Name'
            ),
            'hierarchical' => true,
            'public' => true,
            'show_ui' => true,
            'sort' => true,
            'query_var' => true,
            'args' => array('orderby' => 'term_order'),
            'rewrite' => array('slug' => 'brands', 'with_front' => false),
        )
    );
    }
Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    try this one more time
    – updating your permalinks by choosing the default permalink structure or re-saving your current structure at Settings > Permalinks in your admin panel. WordPress will rebuild the .htaccess file. If WordPress cannot automatically edit the .htaccess file, it will provide manual instructions after saving.

    or:

    – renaming or deleting the .htaccess file by using FTP or whatever file management application your host provides. If you delete it make a backup first.

    just to be sure:
    – deactivating all plugins to see if this resolves the problem? If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    – switching to the default theme to rule out any theme-specific problems?

    Thread Starter nathanadams

    (@nathanadams)

    Hi keesiemeijer, thanks for the response.

    I’ve tried all that you’ve instructed:
    — updating the permalink structure again
    — rename the htaccess file, so that WP generates a new one
    — deactivating all plugins
    — switching to the default twenty eleven theme

    In all cases, the issue still exists.

    With the custom permalink structure, when clicking on the brand it appears to be using the correct url structure (http://www.siteroot.com/brands/brandname/) when showing the 404 page. With the default permalink setting it goes to http://www.siteroot.com/?brand=brandname, which works correctly.

    The recreated .htaccess file is:

    AddHandler php5-script .php
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    Moderator keesiemeijer

    (@keesiemeijer)

    Do you also have a “Page” called “brands”? (or in the trash?)

    Thread Starter nathanadams

    (@nathanadams)

    Yes, I do. I’ve just tried changing the name (and slug) of that page to “brandss” (for the sake of experiment), and that seems to have fixed it.

    Is there a way of reusing the name? What I want to have is a root/brands/ page which has an intro about the brands and a list of all of them, and then have root/brands/brandname for each brand, listing their products.

    Thanks

    Moderator keesiemeijer

    (@keesiemeijer)

    Unfortunately Page slugs and custom taxonomy slugs collide when they are the same. I don’t think it’s possible what you want.

    Thread Starter nathanadams

    (@nathanadams)

    What a pain. Oh well, I guess I’ll try to think of some non-conflicting alternative names. Thanks so much for your help.

    I have the exact same issue as Nathan but i couldn’t fix it yet. I tried to flush the permalinks but it doesn’t work.

    I don’t have a duplicate, since all my new taxonomies have very unique names (site initials, underscores, etc.).

    Any idea why i keep receiving 404 not-found errors?

    Thanks,
    Ciprian

    Exact same problem here, no duplicate either.

    I have the same problem as well. Actually I have 2 custom post types and for one it works perfectly and the other throws an error. No duplicate page names for either.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Category page for custom-taxonomy shows 404 when using custom permalink structur’ is closed to new replies.