By default, a post in WordPress will be assigned to “uncategorized”. If we use a custom taxonomy, say “story” for a “comic” custom post type, there is no default category to fall within anymore.
Since there is no default taxonomy to pass through, the post will return Undefined offset: 0 and Trying to get property of non-object errors if
To fix this, we can use the
“(it) Relates an object (post, link etc) to a term and taxonomy type (tag, category, etc). Creates the term and taxonomy relationship if it doesn’t already exist.”
Now we need to add a default taxonomy for this custom post type, so that if no story (taxonomy) is set, the comic post won’t return errors. Let’s assign all comic posts to “draft” by default.
In functions.php ->
Now any uncategorised comic post will automatically be sorted as a story “draft” without error. The URL will read as http://url/taxonomy/name.
If we go back to the comic administration panel, we see that “draft” is checked.
Know a better way or another method? Please leave a comment below.