taxonomy category shows up in breadcrumbs path with rewrite = false
-
class myCustom_Post{ public $default_portfolio_slug; public $post_type_portfolio = 'portfolio'; public $post_type_taxonomy_portfolio = 'portfolio_category'; public function __construct() { add_action( 'init', array(&$this,'portfolio'), 12); } function portfolio(){ // Default Slug Names $default_portfolio_slug = 'portfolio'; // Slug Names $portfolio_slug = 'portfolio'; // singular portfolio item $labels = array( 'name' => _x('Portfolio items', 'post type general name', 'theme_admin' ), 'singular_name' => _x('Portfolio Item', 'post type singular name', 'theme_admin' ), 'add_new' => _x('Add New', 'portfolio', 'theme_admin' ), 'add_new_item' => __('Add New Portfolio Item', 'theme_admin' ), 'edit_item' => __('Edit Portfolio Item', 'theme_admin' ), 'new_item' => __('New Portfolio Item', 'theme_admin' ), 'view_item' => __('View Portfolio Item', 'theme_admin' ), 'search_items' => __('Search Portfolio Items', 'theme_admin' ), 'not_found' => __('No portfolio item found', 'theme_admin' ), 'not_found_in_trash' => __('No portfolio items found in Trash', 'theme_admin' ), 'parent_item_colon' => '', 'menu_name' => __('Portfolio items', 'theme_admin' ), ); $capabilities = array( 'publish_posts' => 'theme_publish_portfolios', 'edit_post' => 'theme_edit_portfolio', 'edit_posts' => 'theme_edit_portfolios', 'edit_private_posts' => 'theme_edit_private_portfolios', 'edit_published_posts' => 'theme_edit_published_portfolios', 'edit_others_posts' => 'theme_edit_others_portfolios', 'delete_post' => 'theme_delete_portfolio', 'delete_posts' => 'theme_delete_portfolios', 'delete_private_posts' => 'theme_delete_private_portfolios', 'delete_published_posts' => 'theme_delete_published_portfolios', 'delete_others_posts' => 'theme_delete_others_portfolios', 'read_post' => 'theme_read_portfolio', 'read_private_posts' => 'theme_read_private_portfolios', ); $args = array( 'labels' => $labels, 'singular_label' => __('portfolio', 'theme_admin' ), 'public' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'show_ui' => true, 'show_in_menu' => true, //'menu_position' => 20, 'capability_type' => 'portfolio', 'capabilities' => $capabilities, 'hierarchical' => false, 'supports' => array('title', 'editor', 'excerpt', 'thumbnail', 'comments', 'author', 'page-attributes', 'revisions'), 'has_archive' => true, 'rewrite' => array( 'slug' => ! empty($portfolio_slug) ? $portfolio_slug : $default_portfolio_slug, 'with_front' => true, 'pages' => true, 'feeds'=>true ), 'query_var' => true, 'can_export' => true, 'show_in_nav_menus' => true, ); register_post_type('portfolio',$args); // Portfolio Categories $labels_cat = array( 'name' => _x( 'Portfolio Categories', 'taxonomy general name', 'theme_admin' ), 'singular_name' => _x( 'Portfolio Category', 'taxonomy singular name', 'theme_admin' ), 'search_items' => __( 'Search Categories', 'theme_admin' ), 'popular_items' => __( 'Popular Categories', 'theme_admin' ), 'all_items' => __( 'All Categories', 'theme_admin' ), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __( 'Edit Portfolio Category', 'theme_admin' ), 'update_item' => __( 'Update Portfolio Category', 'theme_admin' ), 'add_new_item' => __( 'Add New Portfolio Category', 'theme_admin' ), 'new_item_name' => __( 'New Portfolio Category Name', 'theme_admin' ), 'separate_items_with_commas' => __( 'Separate Portfolio category with commas', 'theme_admin' ), 'add_or_remove_items' => __( 'Add or remove portfolio category', 'theme_admin' ), 'choose_from_most_used' => __( 'Choose from the most used portfolio category', 'theme_admin' ), 'menu_name' => __( 'Categories', 'theme_admin' ), ); $capabilities_cat = array( 'manage_terms' => 'theme_manage_portfolio_terms', 'edit_terms' => 'theme_edit_portfolio_terms', 'delete_terms' => 'theme_delete_portfolio_terms', 'assign_terms' => 'theme_assign_portfolio_terms', ); $args_cat= array( 'hierarchical' => true, 'labels' => $labels_cat, 'capabilities' => $capabilities_cat, 'public' => false, 'show_in_nav_menus' => false, 'show_ui' => true, 'show_tagcloud' => false, 'query_var' => true, 'rewrite' => false, 'show_admin_column' => true, ); register_taxonomy('portfolio_category','portfolio', $args_cat); } } new myCustom_Post();
Please add the above code to the functions.php of twenty twenty theme
1) activate the 20-20 theme and save the permalinks just once.2) Now create two categories for the portfolio items one named videos and one named animals.
3) Now add a new portfolio item just give it any name and set the animals category to that newly created portfolio post and in the post content itself add the yoast breadcrumb shortcode. Publish the post.
4) If you view the post in the front you will see a empty page and the content showing the breadcrumbs path with categories/taxonomy in it.
5) Note: in the Yoast Breadcrumb settings there is no setting for the Taxonomy Portfolio as the rewrite has been set to False. So there is nothing to set for this taxonomy (enable or disable). But the taxonomy still shows up in the breadcrumb path.
Although the categories have no rewrite why does the animal category show up in the breadcrumbs path as a link?
Why is there a breadcrumb path called ‘Portfolio items’ linking to the last portfolio category called video’s? Rerwite has been set to false!The breadcrumb path called ‘Portfolio items’ linking to the last portfolio category called video’s shows up because the register_post_type has a argument called has_archive=> true but the rewrite has been set to false. It should follow the rewrite and not the has_archive in this case.
Where am i making the mistake or where is yoast breadcrumbs making the mistake and adding the categories to the path. In the Yoast breadcrumb settings the custom category is not shown which is correct because of the rewtite=false.
Please advice how to resolve this. Thank you
- The topic ‘taxonomy category shows up in breadcrumbs path with rewrite = false’ is closed to new replies.