Skip to content

Instantly share code, notes, and snippets.

@maxxscho
Created April 16, 2015 08:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxxscho/5baec0479bace2dcaac5 to your computer and use it in GitHub Desktop.
Save maxxscho/5baec0479bace2dcaac5 to your computer and use it in GitHub Desktop.
Wordpress get page ID by slug
/**
* Get a page ID by slug
* @param $page_slug
*
* @return int|null
*/
function bb_get_page_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