[wp-trac] [WordPress Trac] #33825: PHP warning on wp_insert_post, when tax_input variable is string
WordPress Trac
noreply at wordpress.org
Fri Sep 11 14:00:11 UTC 2015
#33825: PHP warning on wp_insert_post, when tax_input variable is string
-------------------------------+----------------------
Reporter: ivan.jankovic | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Posts, Post Types | Version: 4.3
Severity: normal | Resolution: invalid
Keywords: | Focuses:
-------------------------------+----------------------
Changes (by boonebgorges):
* status: new => closed
* resolution: => invalid
* milestone: Awaiting Review =>
Comment:
Hi ivan.jankovic - Thanks for the ticket! Welcome to Trac.
As swissspidy notes, this is expected behavior. Unfortunately, this was
not properly documented in the inline documentation for `wp_insert_post()`
until [33922].
The docs at https://codex.wordpress.org/Function_Reference/wp_insert_post
are actually correct, though they're somewhat confusing:
{{{
'tax_input' => [ array( <taxonomy> => <array | string>,
<taxonomy_other> => <array | string> ) ]
}}}
This means that 'tax_input' must be an array (thus the square brackets),
but that the value of a specific taxonomy key can optionally be a string.
Eg:
{{{
'tax_input' => array( 'post_tag' => array( 3 ), 'category' => array( 5, 7
) )
// or
'tax_input' => array( 'post_tag' => '3', 'category' => '5,7' )
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/33825#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list