I'm using a custom post type "portfolio" to create new posts and categories. I'm trying to retrieve the correct category/taxonomy URL from the post. I'm a couple days in on this and could really use some help. Registering post and tax below:
function portfolioposttype() {
$labels = array(
'name' => __('Portfolio'),
'singular_name' => __('Project'),
'add_new' => __('Add New'),
'add_new_item' => __('Add New Project'),
'edit_item' => __('Edit Project'),
'new_item' => __('New Project'),
'view_item' => __('View Project'),
'search_items' => __('Search Projects'),
'not_found' => __('No projects found'),
'not_found_in_trash' => __('No projects found in Trash'),
'parent_item_colon' => __('Parent Project:'),
'menu_name' => __('Portfolio')
);
$args = array(
'labels' => $labels,
'supports' => array('title','editor','thumbnail'),
'taxonomies' => array('portfolio-categories'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'exclude_from_search' => true,
'has_archive' => true,
'rewrite' => array('slug'=>'case-study'), //singe project slug
'capability_type' => 'post',
'menu_position' => 5,
'menu_icon' => Z_BASE_URL.'functions/assets/img/icon-portfolio.png',
'query_var' => true
);
register_post_type('portfolio', $args );
$taxonomy_portfolio_category_labels = array(
'name' => __('Portfolio Categories'),
'singular_name' => __('Category'),
'search_items' => __('Search Categories'),
'popular_items' => __('Popular Categories'),
'all_items' => __('All Categories'),
'parent_item' => __('Parent Category'),
'parent_item_colon' => __('Parent Category:'),
'edit_item' => __('Edit Category'),
'update_item' => __('Update Category'),
'add_new_item' => __('Add New Category'),
'new_item_name' => __('New Category'),
'separate_items_with_commas' => __('Separate categories with commas'),
'add_or_remove_items' => __('Add or remove Categories'),
'choose_from_most_used' => __('Choose from most used Categories'),
'menu_name' => __('Categories')
);
$taxonomy_portfolio_category_args = array(
'labels' => $taxonomy_portfolio_category_labels,
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array('slug'=>'projects'), //category slug
'query_var' => true
);
register_taxonomy('portfolio-categories',array('portfolio'),$taxonomy_portfolio_category_args);
}
add_action('init','portfolioposttype');
So, from www.domain.com/case-study/sample-project-1
I need to be able to link it back to the category: www.domain.com/projects/category-1
There could be another www.domain.com/case-study/sample-project-2
that would link to www.domain.com/projects/category-2
I hope this makes sense and really appreciate any advice!