[wp-trac] [WordPress Trac] #45171: Adjust wp_insert_post() docs to reflect that the post_category argument will only accept one or more term IDs

WordPress Trac noreply at wordpress.org
Wed Oct 24 22:18:58 UTC 2018


#45171: Adjust wp_insert_post() docs to reflect that the post_category argument
will only accept one or more term IDs
-------------------------------+-----------------------------
 Reporter:  DrewAPicture       |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:
 Severity:  normal             |   Keywords:  good-first-bug
  Focuses:  docs               |
-------------------------------+-----------------------------
 As pointed out by @ck-macleod on the Code Reference, the `post_category`
 argument for `wp_insert_post()` actually only accepts term IDs and not an
 "Array of category names, slugs, or IDs."

 This is due to how adding hierarchical taxonomies terms (like categories)
 works up the stack in `wp_insert_post()` -> `wp_set_post_categories()` ->
 `wp_set_post_terms()`.

 The fix should remove reference to "names" and "slugs" in the
 `$post_category` entry in the hash notation for `wp_insert_post()`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/45171>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list