WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#10865 closed enhancement (wontfix)

Function to get posts based on post title

Reported by: sudar Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Template Keywords:
Focuses: Cc:

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 (1)

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

Download all attachments as: .zip

Change History (9)

comment:1 sudar5 years ago

  • Cc sudar@… added

comment:2 follow-up: hakre5 years ago

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

comment:3 in reply to: ↑ 2 sudar5 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.

sudar5 years ago

Patch with get_post_by_title() function

comment:4 willmot5 years ago

  • 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.

comment:5 hakre5 years ago

sounds interesting and very useable.

comment:6 ryan4 years ago

  • Milestone changed from 2.9 to Future Release

comment:7 sorich874 years ago

  • Resolution set to wontfix
  • Status changed from new to closed

get_page_by_title() now has a post_type parameter

comment:8 nacin4 years ago

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