Make WordPress Core

Changeset 4425


Ignore:
Timestamp:
10/26/2006 07:55:10 PM (18 years ago)
Author:
ryan
Message:

get_page_by_title()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r4419 r4425  
    943943            return get_page($page->ID, $output);
    944944    }
     945
     946    return NULL;
     947}
     948
     949function get_page_by_title($page_title, $output = OBJECT) {
     950    global $wpdb;
     951    $page_title = $wpdb->escape($page_title);
     952    $page = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_title = '$page_title' AND post_type='page'");
     953    if ( $page )
     954        return get_page($page, $output);
    945955
    946956    return NULL;
Note: See TracChangeset for help on using the changeset viewer.