Posted By

adambundy on 07/30/14



Versions (?)

Who likes this?

2 people have marked this snippet as a favorite


Wordpress check if post ID exists

 / Published in: PHP


Thanks to Tom McFarlin for this.

  1. <?php
  3. /**
  4.  * Determines if a post, identified by the specified ID, exist
  5.  * within the WordPress database.
  6.  *
  7.  * Note that this function uses the 'acme_' prefix to serve as an
  8.  * example for how to use the function within a theme. If this were
  9.  * to be within a class, then the prefix would not be necessary.
  10.  *
  11.  * @param int $id The ID of the post to check
  12.  * @return bool True if the post exists; otherwise, false.
  13.  * @since 1.0.0
  14.  */
  15. function acme_post_exists( $id ) {
  16. return is_string( get_post_status( $id ) );
  17. }
  18. ?>

Report this snippet  


RSS Icon Subscribe to comments
Posted By: robertfcrocker on September 14, 2017

This type of message always inspiring and I prefer to read quality content, so happy to find good place to many here in the post, the writing is just great, thanks for the post. official website

You need to login to post a comment.