When working on third-party plugins or a purchased theme, we may encounter a situation where we need to attach an existing taxonomy (created by someone else) to a custom post type we’ve created (in our case, “fruits” — see this article).

Order website or plugin development for WordPress, website development on the Laravel, Symfony, or Yii2 framework…

When working on third-party plugins or a purchased theme, we may encounter a situation where we need to attach an existing taxonomy (created by someone else) to a custom post type we’ve created (in our case, “fruits” — see this article).

Why do we need custom statuses? As always, there are many use cases. I personally used them only once — to mark products that didn’t fall into any category when importing from the Yandex Market.
Below is an example of creating a custom post status. More about all the parameters can be found in the official WordPress Codex. I just want to highlight the following points:

Sometimes there are cases when, in custom post types (created via the `register_post_type()` function), or even in default post types like post or page, we need to disable (remove) the date filter dropdown. This dropdown shows the month and year when posts were created on our site.
Searching the official documentation didn't yield much, so I had to dig into the code and find the necessary filter. I discovered the `disable_months_dropdown` filter, which takes two parameters — the display state of the dropdown and the post type.
Example of using the filter:
add_filter('disable_months_dropdown', function($bool, $post_type) {
if($post_type == 'type_order')
{
return true;
}
return $bool;
}, 1, 2);where:
$bool — whether to display the date dropdown (default is false, meaning the filter is disabled and the dropdown will be shown)
$post_type — the current post type
Note that you can also get the current post type using the `get_current_screen()` function and its `post_type` property. That is:
get_current_screen() -> post_type
And I have a feeling that a similar method could be used to disable the category filter as well (needs to be tested).