[wp-trac] [WordPress Trac] #46441: [WordPress - 5.1] Can't get categories after publishing the post first time on using "transition_post_status" action
WordPress Trac
noreply at wordpress.org
Fri Mar 8 07:06:52 UTC 2019
#46441: [WordPress - 5.1] Can't get categories after publishing the post first time
on using "transition_post_status" action
--------------------------+-----------------------------
Reporter: malayladu | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 5.1
Severity: normal | Keywords: needs-patch
Focuses: |
--------------------------+-----------------------------
When we publish the Post for the first time without doing "Save draft" at
that time we are not getting post categories in the function which is bind
to "transition_post_status" status hook.
We are using "get_the_category" method to get the categories. But, every
time it returns default category.
It works when we do "Save draft" and then "Publish" it.
I suspect it's related to WP_REST_Posts_Controller where "wp_update_post"
method is called and we are not passing "selected categories" into data
and in "wp_update_post" it overwrites post categories with default
category if it's not set.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46441>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list