0

I have a custom taxonomy. I was able to access the list of items with term foo in taxonomy bar at mysite.dev/?bar=foo. I then changed my permalink options from the default to "post name". I can no longer access my taxonomies at /?bar=foo nor at /bar/foo, which is what it directs me to when I go (via the dashboard) to Posts > bar > foo > View. I get a WP 404 (not an Apache 404).

My .htaccess contains only

# 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

and I have tried the MySQL query delete from wp_options where option_name="rewrite_rules" followed by re-saving the permalink settings. There was no change.

Yes, I have cleared caches, via the command line: wp cache flush

The taxonomy is registered in functions.php:

    // Hook to run the function on init
    add_action('init', 'register_taxonomy_topic');

    function register_taxonomy_bar() {
      register_taxonomy(
          'bar', 
          array('post'),
          array(
              'label' => __('Bar'),
              'show_ui' => true,
              'hierarchical' => false,
              'capabilities' => array(
                  'manage_terms' => 'administrator',
                  'edit_terms'   => 'administrator',
                  'delete_terms' => 'administrator',
              )
          )
      );
    }
    add_action('init', 'register_taxonomy_bar');

var_dump($wp_query['request']) gives me SELECT wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_name = 'barfoo' AND wp_posts.post_type = 'post' ORDER BY wp_posts.post_date DESC so I can see it's looking for a post called "barfoo" instead of posts with term "foo" in taxonomy "bar".

I've tried registering the same taxonomy in exactly the same way in the twentyfourteen theme that comes with Wordpress, and I get the same problem. The plugins I have active are: Advanced Custom Fields, Advanced Custom Fields: Nav Menu Field, Advanced Custom Fields Pro, Enhanced Media Library, Google XML Sitemaps, Redirection, SVG Support, The Events Calendar, and Timber. I've tried to disable Redirection to see if that's the problem but it won't allow me to disable it.

I've tried updating everything to the latest version which went smoothly but didn't fix this problem.

What causes this and how do I fix it?

12
  • what does your taxonomy registration code look like? also var_dump($wp_query) in the template to see what WordPress is looking for.
    – Milo
    Jan 13, 2015 at 0:01
  • In which template?
    – beth
    Jan 13, 2015 at 0:10
  • the template that loads when you try to view a term. if you look at the query vars and SQL, you'll see what WordPress is trying to query for.
    – Milo
    Jan 13, 2015 at 0:20
  • It looks like it doesn't get that far.
    – beth
    Jan 13, 2015 at 16:05
  • 1
    your code works in a new install using twentyfourteen, so it's likely one of your plugins breaking things. you'll have to disable all of them and reenable one at a time to determine what's causing it.
    – Milo
    Jan 13, 2015 at 20:49

1 Answer 1

0

I added a rewrite rule manually.

  add_rewrite_rule('^bar([^/]+)(/[0-9]+)?/?$','index.php?bar=$matches[1]','top');

right after

add_action('init', 'register_taxonomy_bar');

in functions.php.

But Wordpress is SERIOUSLY DENSE in translating /bar/foo/ to barfoo?bar=foo and I don't know how to get around this nonsensical "barfoo" in the path. I also have no idea what it'll do to paging. Also this has to be defined for each and every custom taxonomy.

Nevertheless, it works, sort of.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.