Created
April 16, 2015 08:35
-
-
Save maxxscho/5baec0479bace2dcaac5 to your computer and use it in GitHub Desktop.
Wordpress get page ID by slug
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
/** | |
* 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