Monday, July 15, 2013

How to Get ID from Page Name in WordPress Website

This function return ID of page name, add this function on functions.php file of your current template.
function get_ID_by_page_name($page_name) {
global $wpdb;
$page_name_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$page_name."' AND post_type = 'page'");
return $page_name_id;
}

Disqus Comments