Make WordPress Core


Ignore:
Timestamp:
06/26/2014 02:04:38 AM (11 years ago)
Author:
wonderboymusic
Message:

Check for the existence of $post before using it in get_the_ID(). Return false if it doesn't exist.

Props UmeshSingla.
Fixes #17034.

File:
1 edited

Legend:

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

    r28760 r28844  
    2424 * @uses $post
    2525 *
    26  * @return int
     26 * @return int|bool The ID of the current item in the WordPress Loop. False if $post is not set.
    2727 */
    2828function get_the_ID() {
    29     return get_post()->ID;
     29    $post = get_post();
     30    return ! empty ( $post ) ? $post->ID : false;
    3031}
    3132
Note: See TracChangeset for help on using the changeset viewer.