Opened 5 years ago
Last modified 2 months ago
#50435 new defect (bug)
In some cases wp_get_post_parent_id() = get_post_ancestors
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.4.2 |
Component: | Posts, Post Types | Keywords: | |
Focuses: | performance | Cc: |
Description
Using wp_get_post_parent_id() while parsing gutenberg blocks in a save_post action, I found out, that when a parent page exists, and parent_id is the actual published post wp_get_post_parent_id() gives back the post_id of the parent page.
A turn around seems to be ($postParent == $postId) ? $post_current_ID : $postId;
Change History (2)
Note: See
TracTickets for help on using
tickets.
Hi @chvon7thal,
Tested all scenarios for replicating this issue but was not able to get the wp_get_post_parent_id() to return the same ID as the current post ID. Can you please explain the correct scenario with some video so that it will be helpful to debug it.