Ticket #10865 (closed enhancement: wontfix)

Opened 2 years ago

Last modified 18 months ago

Function to get posts based on post title

Reported by: sudar Owned by:
Priority: normal Milestone:
Component: Template Version:
Severity: normal Keywords:
Cc: sudar@…, willmot

Description

Right now we don't have a template function to get posts based on the post title.

We have a function called get_page_by_title (in wp-includes/post.php) which retrieves pages (but not posts) based on title.

I propose a new function get_post_by_title() which could retrieve posts gives page titles.

Attachments

get_post_by_title.patch Download (889 bytes) - added by sudar 2 years ago.
Patch with get_post_by_title() function

Change History

  • Cc sudar@… added

comment:2 follow-up: ↓ 3   hakre2 years ago

please add a description of the possible return values to the docblock comment.

comment:3 in reply to: ↑ 2   sudar2 years ago

Replying to hakre:

please add a description of the possible return values to the docblock comment.

Updated the patch with description of the possible return values to the docblock comment.

sudar2 years ago

Patch with get_post_by_title() function

  • Cc willmot added
  • Milestone changed from Unassigned to 2.9

I'd like to take this further and bring the get_post functionality inline with get_terms by adding a

get_post_by( 'field', 'value', $args = optional ( 'post_type' and/or 'post_status ) ); function.

I'll write a patch if there's any interest.

sounds interesting and very useable.

comment:6   ryan2 years ago

  • Milestone changed from 2.9 to Future Release
  • Status changed from new to closed
  • Resolution set to wontfix

get_page_by_title() now has a post_type parameter

  • Milestone Future Release deleted
Note: See TracTickets for help on using tickets.