Hi Guys,
Don't know if anyone else has encountered this before, but I have added registered a custom post type and on the page the breadcrumb's link is displaying like this:
http://example.com/portfolio/example/0/
Adding a zero at the end... I've tried refreshing permalinks, but not sure what could be causing this.
Any help would be greatly appreciated.
Cheers,
Hayden
It is also worth mentioning that the url shouldn't be the full URL, the breadcrumb is dispalying like this Home / Portfolio / Example (the link is on portfolio so shouldn't be full url just http://example.com/portfolio/)
Here is the code used:
if ( ! function_exists('custom_post_type') ) {
// Register Custom Post Type
function custom_post_type() {
$labels = array(
'name' => 'Portfolio',
'singular_name' => 'Portfolio',
'menu_name' => 'Portfolio',
'name_admin_bar' => 'Portfolio',
'archives' => 'Portfolio Archives',
'attributes' => 'Portfolio Attributes',
'parent_item_colon' => 'Parent Item:',
'all_items' => 'All Portfolios',
'add_new_item' => 'Add New Portfolio',
'add_new' => 'Add New Portfolio',
'new_item' => 'New Portfolio',
'edit_item' => 'Edit Portfolio',
'update_item' => 'Update Item',
'view_item' => 'View Item',
'view_items' => 'View Items',
'search_items' => 'Search Portfolio',
'not_found' => 'Not found',
'not_found_in_trash' => 'Not found in Trash',
'featured_image' => 'Featured Image',
'set_featured_image' => 'Set featured image',
'remove_featured_image' => 'Remove featured image',
'use_featured_image' => 'Use as featured image',
'insert_into_item' => 'Insert into item',
'uploaded_to_this_item' => 'Uploaded to this item',
'items_list' => 'Items list',
'items_list_navigation' => 'Items list navigation',
'filter_items_list' => 'Filter items list',
);
$rewrite = array(
'slug' => 'portfolio',
'with_front' => true,
'pages' => false,
'feeds' => true,
);
$args = array(
'label' => 'Portfolio',
'description' => 'Portfolio',
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'menu_icon' => 'dashicons-Portfolios',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
'show_in_rest' => false,
);
register_post_type( 'custom_post_type', $args );
}
add_action( 'init', 'custom_post_type', 0 );
}