I'm having a hard time explaining this, so bare with me.
Category and tag links for my custom post type aren't working as I expected them to. Instead of getting http://www.example.com/projects/category/example-category
, the links that are http://www.example.com/category/example-category
. In other words, I can't figure out how to make my categories post-type specific. In the dashboard, my Projects post type has both a Tags and a Categories section, but editing them results in the same changes being made to the main Posts post type.
How can I create post-type specific categories?
Here's my code to create the post type:
function projects_create_post_type() {
$labels = array(
"add_new" => "Add New",
"add_new_item" => "Add New",
"all_items" => "All Projets",
"edit_item" => "Edit",
"menu_name" => "Projects",
"name" => "Projects",
"new_item" => "New",
"not_found" => "No projects found",
"not_found_in_trash" => "No projects found in Trash",
"search_items" => "Search Projects",
"singular_name" => "Project",
"view_item" => "View",
);
$args = array(
"has_archive" => true,
"hierarchical" => false,
"labels" => $labels,
"menu_icon" => __("dashicons-hammer"),
"menu_position" => 5,
"public" => true,
"slug" => "projects",
"supports" => array(
"editor",
"thumbnail",
"title",
),
"taxonomies" => array("post_tag", "category"),
);
register_post_type("projects", $args);
}
add_action("init", "projects_create_post_type");