Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#16590 closed defect (bug) (invalid)

get_page_by_title doesn't work for cutom pages

Reported by: o----o Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords:
Focuses: Cc:


get_page_by_title() queried for custom pages returns NULL

Change History (4)

#1 @o----o
5 years ago

sorry, I have forgotten WP 3.0.5

#2 @duck_
5 years ago

  • Keywords reporter-feedback close added

If you mean it's not working for custom post types are you correctly specifying the post type you want to look up?

The function signature is:

get_page_by_title($page_title, $output = OBJECT, $post_type = 'page')

So if you want to retrieve an 'album' post type, for example, you would use:

get_page_by_title( 'Album Title', OBJECT, 'album' )

#3 @johnbillion
4 years ago

  • Keywords reporter-feedback close removed
  • Resolution set to invalid
  • Status changed from new to closed

Definitely works as expected with the $post_type parameter in place.

#4 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.