WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 months ago

Last modified 3 months ago

#38435 closed defect (bug) (duplicate)

Wrong documentation for wp_insert_post

Reported by: nabil_kadimi Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.2
Component: Posts, Post Types Keywords: has-patch good-first-bug
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 3 years ago.
wp_insert_post_docs.2.diff (6.9 KB) - added by nabil_kadimi 3 years ago.
Corrected patch.
wp_insert_post_docs.3.diff (961 bytes) - added by nabil_kadimi 3 years ago.
Corrected patch.

Download all attachments as: .zip

Change History (13)

@nabil_kadimi
3 years ago

Corrected patch.

#1 @nabil_kadimi
3 years ago

  • Type changed from enhancement to defect (bug)

#2 @nabil_kadimi
3 years ago

Just noticed only arrays are working, updating patch again.

@nabil_kadimi
3 years ago

Corrected patch.

#3 @kovshenin
3 years 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.


3 years ago

#5 @helen
3 years ago

  • Version changed from trunk to 4.2

#6 @desrosj
5 months ago

  • Keywords needs-refresh good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

@nabil_kadimi are you able to refresh the patch and make the changes @kovshenin suggested?

#7 @angelagibson
5 months ago

I'm new to contributing but I took a look at this. If I understand correctly, after reviewing the code it looks like the updates referenced above have already been made. wp_set_post_categories() and wp_insert_post() were both changed in ticket:45171 changeset:44660. wp_set_post_terms() was updated in ticket:42505 changeset:42664

This ticket was mentioned in Slack in #core by hareesh-pillai. View the logs.


3 months ago

#9 @Hareesh Pillai
3 months ago

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #45171.

Closing this ticket as the proposed change is already made.

#10 @SergeyBiryukov
3 months ago

  • Component changed from General to Posts, Post Types
  • Keywords needs-refresh removed
  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.