WordPress.org

Make WordPress Core

Opened 7 weeks ago

Last modified 7 weeks ago

#50435 new defect (bug)

In some cases wp_get_post_parent_id() = get_post_ancestors

Reported by: chvon7thal 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 (1)

#1 @SergeyBiryukov
7 weeks ago

  • Component changed from General to Posts, Post Types
Note: See TracTickets for help on using tickets.