WordPress.org

Make WordPress Core

Opened 13 months ago

Last modified 12 months ago

#38435 new defect (bug)

Wrong documentation for wp_insert_post

Reported by: nabil_kadimi Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.2
Component: General Keywords: has-patch
Focuses: docs Cc:

Description

The post_category parameter accepts IDs or array of IDs, the doc says: "Array of category names, slugs, or IDs".

Here's a patch.

Attachments (3)

wp_insert_post_docs.diff (6.9 KB) - added by nabil_kadimi 13 months ago.
wp_insert_post_docs.2.diff (6.9 KB) - added by nabil_kadimi 13 months ago.
Corrected patch.
wp_insert_post_docs.3.diff (961 bytes) - added by nabil_kadimi 13 months ago.
Corrected patch.

Download all attachments as: .zip

Change History (8)

@nabil_kadimi
13 months ago

Corrected patch.

#1 @nabil_kadimi
13 months ago

  • Type changed from enhancement to defect (bug)

#2 @nabil_kadimi
13 months ago

Just noticed only arrays are working, updating patch again.

@nabil_kadimi
13 months ago

Corrected patch.

#3 @kovshenin
13 months ago

  • Keywords has-patch added

Might also be worth fixing the docs in the other related functions:

  • wp_set_post_categories
  • wp_set_post_terms

For reference, from wp_set_post_terms:

/*
 * Hierarchical taxonomies must always pass IDs rather than names so that
 * children with the same names but different parents aren't confused.
 */
if ( is_taxonomy_hierarchical( $taxonomy ) ) {
	$tags = array_unique( array_map( 'intval', $tags ) );
}

This ticket was mentioned in Slack in #core by helen. View the logs.


12 months ago

#5 @helen
12 months ago

  • Version changed from trunk to 4.2
Note: See TracTickets for help on using tickets.