When on a post of the type that you are expecting to see the notices, open your developer console and check the contents of require_post_category.taxonomies for your custom taxonomy.
And make sure when you register your taxonomy that you associate it with your post type using the object_type argument.
Also, please paste your code where you are using the rpc_post_types filter to add your requirements.
Thanks but no luck yet. Console shows the Object: { message: “Choose this…”} but the UI shows nothing.
Here’s how I unset for post and try to set for custom_post and page:
// require post category on custom post type
function custom_rpc_post_types( $post_types ) {
unset($post_types['post']);
$post_types['custom_post'] = array( 'custom_cat' => array(
'message' => "Choose this..."
) );
$post_types['page'] = array( 'custom_cat' => array(
'message' => "Choose that..."
) );
return $post_types;
}
add_filter( 'rpc_post_types', 'custom_rpc_post_types' );
-
This reply was modified 6 years, 4 months ago by
Sanapaino.
Tested and that code is working. I created a custom_cat taxonomy, assigned it to the page post type. Opened a page for editing and I have a notice that says “Choose that…”.
Screenshot
And the require_post_category.taxonomies JavaScript object displays like this:
custom_cat:
message: "Choose that..."
type: "hierarchical"
Screenshot
Possible plugin conflict on your installation?
-
This reply was modified 6 years, 4 months ago by
Josh Hartman.
-
This reply was modified 6 years, 4 months ago by
Josh Hartman.
Sorry, no. I’ve tried with and without any (other) plugins and in three different themes (incl. default 2020) and three different installations in public and local servers. And four browsers. For post with standard categories everything is fine but custom posts or taxonomies, no.
Hmmm. Well I dug deeper and found an issue. So, if you register a taxonomy from scratch and don’t set a rest_base it will return false, but I was testing with taxonomies created with Custom Post Types UI which has a default rest_base of null. So I needed to check for both in my code to make sure there is not a custom rest_base set.
Please update to v2.0.2 and try it out. Thanks!
Yes! That did the trick. Thank you.