1

I Created a custom taxonomy for my projects custom post type.

function projects_taxonomy() {
  $labels = array(
    'name'              => __('projects Categories'),
    'singular_name'     => __('project Category'),
    'search_items'      => __('Search project Categories'),
    'all_items'         => __('All project Categories'),
    'parent_item'       => __('Parent project Category'),
    'parent_item_colon' => __('Parent project Category:'),
    'edit_item'         => __('Edit project Category'), 
    'update_item'       => __('Update project Category'),
    'add_new_item'      => __('Add New project Category'),
    'new_item_name'     => __('New project Category'),
    'menu_name'         => __('project Categories'),
    'rewrite' => array('slug' => 'projects', 'with_front' => true)
  );
  $args = array(
    'labels' => $labels,
    'hierarchical' => true,
  );
  register_taxonomy('projects-category', 'projects', $args);
}

The problem is the taxonomy rewrite is not working correctly and links to tax archive pages look like this:

http://www.domain.com/projects-category/first-cat/

instead of (what i expect):

http://www.domain.com/projects/first-cat/

I tried regenerating htaccess file through permalinks settings a few times. and also checked my syntax with wordpress codex and it seems okay. does it need to be enabled somehow?

4

You have the rewrite argument defined inside the $labels array, move it out to the $args array:

$args = array(
    'labels' => $labels,
    'hierarchical' => true,
    'rewrite' => array('slug' => 'projects', 'with_front' => true)
);
1
  • Foolish of me to expect it working like that! thank you very much for the help Milo
    – Nojan
    May 11 '13 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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