Make WordPress Core

Opened 6 years ago

Last modified 20 months ago

#50435 new defect (bug)

In some cases wp_get_post_parent_id() = get_post_ancestors

Reported by: chvon7thal Owned by:
Priority: normal Milestone: Awaiting Review
Component: Posts, Post Types Version: 5.4.2
Severity: normal Keywords:
Cc: Focuses: performance

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)

#1 @SergeyBiryukov
6 years ago

  • Component General → Posts, Post Types

#2 @karthickmurugan
20 months ago

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.

Note: See TracTickets for help on using tickets.