get_page_by_title

Sponsored Link

投稿に対してタイトルを返します。同じタイトルの投稿が複数ある場合、最小IDの投稿を返します。

この関数はMySQL ‘=’ 比較を使用するので、$page_titleは、通常デフォルトの照合で反応しないケースとして一致されます。

Sponsored Link

Retrieves a post given its title. If more that one post uses the same title, the post with the smallest ID will be returned.

Because this function uses the MySQL ‘=’ comparison the $page_title will usually be matched as case insensitive with default collating.

get_page_by_titleのファンクションタグ使用方法

<?php 
  get_page_by_title( $page_title, $output, $post_type );
?>

get_page_by_titleのパラメーター

$page_title.

(string) (required) Page title
Default: None

$output

(string) (optional) Output type. OBJECT, ARRAY_N, or ARRAY_A.
Default: OBJECT

$post_type

(string) (optional) Post type.
Default: page

戻り値

(mixed)
OBJECT, ARRAY_N, or ARRAY_A.

wp_list_pagesで除外で使用するためのページIDを見つける方法

この例では、”About”というタイトルのページのために$pageオブジェクトを返します。その後、$page->ID要素はページをリスト表示する時にAboutページを除外するために使用します。

This example will return the $page object for the page titled “About”. Then the $page->ID element is used to exclude the About page when listing pages.

<?php 
$page = get_page_by_title( 'About' );
wp_list_pages( 'exclude=' . $page->ID );
?>

注釈

Uses global: (object) $wpdb

変更ログ

Since: 2.1.0
3.0.0: $post_type Parameter was added.

ソースファイル

get_page_by_title()は、wp-includes/post.php内に位置しています。

get_page_by_title() is located in wp-includes/post.php.

関連ファンクションタグ

Page Tags: get_all_page_ids(), get_ancestors(), get_page(), get_page_link(), get_page_by_path(), get_page_by_title(), get_page_children(), get_page_hierarchy(), get_page_uri(), get_pages(), is_page(), page_uri_index(), wp_list_pages(), wp_page_menu()

Sponsored Link