Return to Snippet

Revision: 31373
at September 3, 2010 18:29 by levinet


Initial Code
function getPageByName($page_name) {
	global $wpdb;
	$page_name_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$page_name."'");
	return $page_name_id;
}

Initial URL

                                

Initial Description
Returns the post or page id using the name/slug of a page.

Initial Title
WordPress - Get Post or Page ID By Name

Initial Tags
php, page, wordpress

Initial Language
PHP