wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema
get_page_by_title is deprecated since version 6.2.0!
Alternative: WP_Query
Alternative: WP_Query
get_page_by_title › WordPress Function
Desde2.1.0
Obsoleto6.2.0
› get_page_by_title ( $page_title, $output = OBJECT, $post_type = 'page' )
Parâmetros: (3) |
|
Retorna: |
|
Definido em: |
|
Codex: | |
Log de mudanças: |
|
Retrieves a page given its title.
If more than one post uses the same title, the post with the smallest ID will be returned. Be careful: in case of more than one post having the same title, it will check the oldest publication date, not the smallest ID. Because this function uses the MySQL '=' comparison, $page_title will usually be matched as case-insensitive with default collation.Funções relacionadas: get_page_by_path, get_admin_page_title, get_the_title, get_page_children, get_page_statuses
Fonte
function get_page_by_title( $page_title, $output = OBJECT, $post_type = 'page' ) { _deprecated_function( __FUNCTION__, '6.2.0', 'WP_Query' ); global $wpdb; if ( is_array( $post_type ) ) { $post_type = esc_sql( $post_type ); $post_type_in_string = "'" . implode( "','", $post_type ) . "'"; $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type IN ($post_type_in_string)", $page_title ); } else { $sql = $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type = %s", $page_title, $post_type ); } $page = $wpdb->get_var( $sql ); if ( $page ) { return get_post( $page, $output ); } return null; }