WordPress.org

Make WordPress Core

Opened 4 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:

Description

get_page_by_title() queried for custom pages returns NULL

Change History (4)

comment:1 @o----o4 years ago

sorry, I have forgotten WP 3.0.5

comment:2 @duck_4 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' )

comment:3 @johnbillion4 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.

comment:4 @SergeyBiryukov4 years ago

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