[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:20:12 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 | Resolution:
Keywords: good-first-bug | Focuses: docs
-------------------------------+------------------------------
Description changed by DrewAPicture:
Old description:
> 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()`.
New description:
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()`.
{{{
#!php
* @type array $post_category Array of category names, slugs,
or IDs.
}}}
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#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list