Posted By

simonbouchard on 08/13/10


Tagged

wordpress function


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jamalmohamed
athanassiadis


WordPress: Get Page ID (Function)


 / Published in: PHP
 

This custom function is useful if you want to get the ID of a page.

  1. function get_page_id($page_name) {
  2. global $wpdb;
  3. $page_name = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '".$page_name."'");
  4. return $page_name; }

Report this snippet  

You need to login to post a comment.