Make WordPress Core

Opened 9 years ago

Closed 8 years ago

#34480 closed enhancement (duplicate)

get_the_content inconsistent with get_the_title

Reported by: atomicjack's profile atomicjack Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.4
Component: Posts, Post Types Keywords: has-patch 2nd-opinion
Focuses: template Cc:


get_the_title accepts a post id parameter, to target a specific post outside of the loop; one would assume that get_the_content would work the same way.

That is not the case.

get_the_content does not currently accept a post id as the first parameter - which goes against what would be assumed after having used get_the_title.

TLDR: add post id parameter to get_the_content.

Attachments (2)

34480.diff (1.5 KB) - added by MikeHansenMe 9 years ago.
34480-2.diff (1.5 KB) - added by MikeHansenMe 9 years ago.
use $post instead of $id

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
9 years ago

  • Component changed from General to Posts, Post Types
  • Focuses template added

#2 @swissspidy
9 years ago

Note: get_the_excerpt() doesn't support a post parameter either. It has a deprecated function argument though.

9 years ago

#3 @MikeHansenMe
9 years ago

  • Keywords has-patch 2nd-opinion added

34480.diff add the additional id param to both get_the_content and get_the_excerpt. It is a bit strange that they are in different positions (second and third) and after deprecated params but the use case seems to make sense.

#4 @knutsp
9 years ago

Param name should be $post, not $id, I beleive. See #34234.

9 years ago

use $post instead of $id

#5 @ocean90
8 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

get_the_excerpt() was fixed in [36319].

get_the_content() is a duplicate #11890.

Note: See TracTickets for help on using tickets.