Make WordPress Core

Opened 9 years ago

Closed 8 years ago

Last modified 8 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
9 years ago

sorry, I have forgotten WP 3.0.5

#2 @duck_
9 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
8 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
8 years ago

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