WordPress | Function get page by title

Prem Tiwari - - WordPress Core

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

Prem Tiwari

Prem Tiwari is the founder of FreeWebMentor.com and also a professional developer and a blogger by hobby.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.