WordPress | Function get page by title

WordPress | Function get_page_by_title() retrieves a post given its title. If more than 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.



(string) (required) Page title

Default: None
(string) (optional) Output type. OBJECTARRAY_N, or ARRAY_A.

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

Default: page

Return Values

OBJECTARRAY_N, or ARRAY_A. NULL when no posts found.


File: wp-includes/post.php

get_page_by_title Function WordPress Developer Resources

Examples 1: Find Page ID to use with exclude in wp_list_pages

Examples 2: How To Find WordPress Page ID By Title Then Replace the_content()

Examples 2:  How to Find WordPress Custom Post Type by Title

Refference: https://codex.wordpress.org/Function_Reference/get_page_by_title

If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.

Recommended Posts: