Functions like get_cat_ID
and get_category_by_slug
only work for core post categories (taxonomy category
) – you are dealing with a custom taxonomy todocategories
.
I see you have $a2zq3_cat_name="Category-name";
hardcoded near the top, so I assume you’re not assigning the todocategories
from POST data.
In which case just use wp_set_object_terms()
like so.
wp_set_object_terms( $a2z3_entry_post_id, [ 'the-category-slug' ], 'todocategories' );
… where the-category-slug
is the slug of the todo category you’re trying to assign.
Always make sure to check the documentation for WordPress functions before you try using them.