Last active
September 26, 2018 13:17
-
-
Save paulvanbuuren/6d9f10da72abe560e3117e6b05d620ab to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Retrieve a post ID for a slug and post type | |
*/ | |
function get_postid_by_slug( $page_slug = '', $posttype = 'post' ) { | |
if ( $page_slug ) { | |
$postobject = get_page_by_path( $page_slug, OBJECT, $posttype ); | |
if ( $postobject ) { | |
return $postobject->ID; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment