Skip to content

Instantly share code, notes, and snippets.

@colorful-tones
Forked from davidpaulsson/wp-get_id_by_slug
Last active August 29, 2015 14:19
Show Gist options
  • Save colorful-tones/15a7a1f780858f58c195 to your computer and use it in GitHub Desktop.
Save colorful-tones/15a7a1f780858f58c195 to your computer and use it in GitHub Desktop.
// Usage:
// get_id_by_slug( 'any-page-slug' );
function get_id_by_slug( $page_slug ) {
$page = get_page_by_path( $page_slug );
if ( $page ) {
return $page->ID;
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment