Definition:
function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) {}
Retrieve a page given its title.
Parameters
- string $page_title: Page title
- string $output: Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
- string $post_type: Optional. Post type. Default page.
Source code
function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) {
global $wpdb;
$page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
if ( $page )
return get_page($page, $output);
return null;
}
1532

February 12, 2011 


No comments yet... Be the first to leave a reply!