WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/17/2021 03:23:40 AM (2 months ago)
Author:
peterwilsoncc
Message:

Posts, Post Types: Use global post as the default for wp_get_post_parent_id().

Convert the $post parameter of wp_get_post_parent_id() to optional, defaulting to the current global post object when called within the loop.

Props danielpost, davidbaumwald, SergeyBiryukov, birgire, audrasjb, hellofromTonya, TimothyBlynJacobs.
Fixes #48358.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r52158 r52194  
    76437643 *
    76447644 * @since 3.1.0
    7645  *
    7646  * @param int|WP_Post $post Post ID or post object.
     7645 * @since 5.9.0 The `$post` parameter was made optional.
     7646 *
     7647 * @param int|WP_Post|null $post Optional. Post ID or post object. Defaults to global $post.
    76477648 * @return int|false Post parent ID (which can be 0 if there is no parent),
    76487649 *                   or false if the post does not exist.
    76497650 */
    7650 function wp_get_post_parent_id( $post ) {
     7651function wp_get_post_parent_id( $post = null ) {
    76517652    $post = get_post( $post );
    76527653    if ( ! $post || is_wp_error( $post ) ) {
Note: See TracChangeset for help on using the changeset viewer.