If you donβt mind, can you tell me what hook the product CPT is registered in? I think I know what is going on, but want confirmation as to when the CPT is registered.
Hi John,
Are you talking about that?
add_action( 'init', 'cpt_product', 0 );
That would be it. Looks like it is probably running after the period of time the plugin checks for CPTs (as I had thought), I’m tracking this bug here: https://github.com/mtekk/Breadcrumb-NavXT/issues/210
So for the moment, impossible to fix the problem?
So, looking into this, I’m unfortunately having issues reproducing it locally. The only thing I can get to show up is warnings on the frontend if the priority of the add_action call on the init action is at 11 or “lower” (any number greater than 10). Is your call to add_action in a plugin, or somewhere else? Is it running within a function that hooks into an action? If so what action?
-
This reply was modified 7 years, 7 months ago by
John Havlik.
The code is in “functions.php”.
Here is my code:
function cpt_product() {
$labels = array(
'name' => 'Products',
'singular_name' => 'Products',
'menu_name' => 'Products',
'name_admin_bar' => 'Products',
'all_items' => 'All Products',
'add_new_item' => 'Add New Product',
'add_new' => 'Add New',
'new_item' => 'New Product',
'edit_item' => 'Edit Product',
'update_item' => 'Update Product',
'view_item' => 'View Product',
'view_items' => 'View Products',
'search_items' => 'Search Product',
);
$rewrite = array(
'slug' => 'product',
'with_front' => true,
'pages' => true,
'feeds' => true,
);
$args = array(
'label' => 'Product',
'description' => 'Products',
'labels' => $labels,
'supports' => array( 'title', 'thumbnail' ),
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 20,
'menu_icon' => 'dashicons-products',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => 'product',
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
'capability_type' => 'page',
);
register_post_type( 'product', $args );
}
add_action( 'init', 'cpt_product', 0 );
Thanks for that, it looks like there was a bug in the handling for hierarchical CPT default settings (I was testing with non-hierarchical CPTs out of convenience which is obviously an issue). I’m now able to reproduce this locally and will be issuing an update with a fix this week (6.2.1).
Good news!!!
I look forward. π
There should be a fixed version available up on github now.
Ok, thanks and in WordPress?
Breadcrumb NavXT 6.2.1 was released yesterday (2018-10-26).
It works!
Thank you so much! π