WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#4844 closed enhancement (fixed)

Need set_post_type API

Reported by: filosofo Owned by:
Milestone: 2.5 Priority: normal
Severity: normal Version: 2.3
Component: General Keywords: set_post_type post_type has-patch
Focuses: Cc:

Description

Currently there is a get_post_type function, which with other functions allows plugins to use custom "post_type"s. There should be API to set the post_type without having to access the db directly.

Attachments (2)

set_post_type.diff (579 bytes) - added by filosofo 7 years ago.
set_post_type.2.diff (656 bytes) - added by filosofo 7 years ago.

Download all attachments as: .zip

Change History (7)

filosofo7 years ago

filosofo7 years ago

comment:1 filosofo7 years ago

The second patch sanitizes post_type per rboren's suggestion at comment:ticket:4991:1

comment:2 follow-up: ryan7 years ago

I think this needs to use wp_update_post() so that all of the right actions are triggered.

comment:3 in reply to: ↑ 2 filosofo7 years ago

Replying to ryan:

I think this needs to use wp_update_post() so that all of the right actions are triggered.

One advantage to a stand-alone function instead of just using wp_update_post() is that you don't have to know all of the post data first.

Also, other aspects of a post can be changed without going through wp_update_post, such as categories, tags, ping URLs, and post meta-data.

And you keep the API parallel: where there's a get_* there should be a set_* or update_*

comment:4 ryan6 years ago

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

(In [6537]) set_post_type from filosofo. fixes #4844

comment:5 ryan6 years ago

I added db prepare and some phpdoc, hopefully didn't break anything.

Note: See TracTickets for help on using tickets.