Created
October 6, 2015 19:51
-
-
Save mattmcgiv/a060bf2a0909372aab5b to your computer and use it in GitHub Desktop.
WordPress does post exist (by id)?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Determines if a post, identified by the specified ID, exist | |
| * within the WordPress database. | |
| * | |
| * Note that this function uses the 'acme_' prefix to serve as an | |
| * example for how to use the function within a theme. If this were | |
| * to be within a class, then the prefix would not be necessary. | |
| * | |
| * @param int $id The ID of the post to check | |
| * @return bool True if the post exists; otherwise, false. | |
| * @since 1.0.0 | |
| */ | |
| function acme_post_exists( $id ) { | |
| return is_string( get_post_status( $id ) ); | |
| } | |
| //source: https://tommcfarlin.com/wordpress-post-exists-by-id/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment