Monday, September 3, 2012

Get the page ID by the page name

function get_id_by_post_name($post_name)
{
global $wpdb;
$id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$post_name."' AND post_status='publish'");
return $id;


 

No comments:

Post a Comment