[wp-trac] [WordPress Trac] #33045: New conditional tags for child/parent pages
    WordPress Trac 
    noreply at wordpress.org
       
    Thu Jun  6 07:20:05 UTC 2019
    
    
  
#33045: New conditional tags for child/parent pages
-------------------------------+-----------------------------
 Reporter:  ramiy              |       Owner:  johnbillion
     Type:  enhancement        |      Status:  reviewing
 Priority:  normal             |   Milestone:  Future Release
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:
 Keywords:  has-patch          |     Focuses:  template
-------------------------------+-----------------------------
Comment (by birgire):
 In [attachment:"33045.6.patch"] for the {{{has_post_parent()}}} docs,
 there's currently:
 {{{
 * @return int
 }}}
 but it should be:
 {{{
  * @return bool
 }}}
 Regarding the naming, I would assume beforehand that
 {{{get_post_parent()}}} would return the post parent object, just as
 {{{get_post()}}}.
 But beside from that, we already have this function in core:
 {{{
 /**
  * Returns the ID of the post's parent.
  *
  * @since 3.1.0
  *
  * @param int|WP_Post $post Post ID or post object. Defaults to global
 $post.
  * @return int|false Post parent ID (which can be 0 if there is no
 parent), or false if the post does not exist.
  */
 function wp_get_post_parent_id( $post ) {
         $post = get_post( $post );
         if ( ! $post || is_wp_error( $post ) ) {
                 return false;
         }
         return (int) $post->post_parent;
 }
 }}}
 See
 https://developer.wordpress.org/reference/functions/wp_get_post_parent_id/
-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/33045#comment:26>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
    
    
More information about the wp-trac
mailing list