I’ve registered a customized taxonomy for a customized put up sort. Each time period on the admin time period record web page has a hyperlink to the record of posts filtered by that time period.
This hyperlink ought to seem like this:
for a customized put up sort:
…/edit.php?taxonomy-name=taxonomy-term-name&post_type=post-type-name
for posts:
…/edit.php?taxonomy-name=taxonomy-term-name
Nonetheless, for my taxonomy the hyperlinks don’t have the post_type argument, leading to hyperlinks like .../edit.php?taxonomy-name=taxonomy-term-name
which makes the hyperlinks result in common posts
record filtered by a time period of a taxonomy they do not have. I am unable to determine why that is.
My code:
//register a put up sort in a plugin
add_action( 'init', 'register_post_type_tdlrm_store_item', 10 );
perform register_post_type_tdlrm_store_item() {
$labels = array(
//omitted
);
$args = array(
'label' => __( 'Merchandise', 'text_domain' ),
'description' => __( 'Retailer objects', 'text_domain' ),
'labels' => $labels,
'helps' => array( 'title', 'editor', 'thumbnail', 'feedback', 'revisions' ),
'taxonomies' => array( 'store-category' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => false,
'menu_position' => 5,
'menu_icon' => 'dashicons-cart',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'put up',
'rewrite' => array('slug' => 'product')
);
$args = apply_filters('tdlrm_filter: tdlrm_store_item: alter register_post_type arguments', $args);
register_post_type( 'tdlrm_store_item', $args );
}
//register taxonomy in one other plugin
add_action( 'init', 'register_ingredients_taxonomy', 99);
perform register_ingredients_taxonomy(){
$labels = array(
//omitted
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => false,
'rewrite' => array( 'slug' => 'ingredient' ),
);
register_taxonomy( 'tdlrm_ingredients', array( 'tdlrm_store_item' ), $args );
}
//I attempted to repair the state of affairs
add_filter('tdlrm_filter: tdlrm_store_item: alter register_post_type arguments', 'alter_post_type_arguments');
perform alter_post_type_arguments($arguments){
if(!in_array('tdlrm_ingredients', $arguments['taxonomies'])){
$arguments['taxonomies'][] = 'tdlrm_ingredients';
}
return $arguments;
}
I do not perceive why this provides me incorrect hyperlinks.
Additionally, I’ve re-saved permalinks simply in case, to no impact.