WordPress.org

Make WordPress Core

Changeset 13899


Ignore:
Timestamp:
03/31/2010 08:20:28 AM (10 years ago)
Author:
nacin
Message:

Add post type parameter to get_page_by_title(). props mikeschinkel, fixes #12743.

File:
1 edited

Legend:

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

    r13829 r13899  
    27522752 *
    27532753 * @param string $page_path Page path
    2754  * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
     2754 * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
     2755 * @param string $post_type Optional. Post type. Default page.
    27552756 * @return mixed Null when complete.
    27562757 */
     
    27942795 *
    27952796 * @param string $page_title Page title
    2796  * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A.
     2797 * @param string $output Optional. Output type. OBJECT, ARRAY_N, or ARRAY_A. Default OBJECT.
     2798 * @param string $post_type Optional. Post type. Default page.
    27972799 * @return mixed
    27982800 */
    2799 function get_page_by_title($page_title, $output = OBJECT) {
     2801function get_page_by_title($page_title, $output = OBJECT, $post_type = 'page' ) {
    28002802    global $wpdb;
    2801     $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='page'", $page_title ));
     2803    $page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type= %s", $page_title, $post_type ) );
    28022804    if ( $page )
    28032805        return get_page($page, $output);
Note: See TracChangeset for help on using the changeset viewer.