WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#34480 closed enhancement (duplicate)

get_the_content inconsistent with get_the_title

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

Description

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 5 years ago.
34480-2.diff (1.5 KB) - added by MikeHansenMe 5 years ago.
use $post instead of $id

Download all attachments as: .zip

Change History (7)

#1 @SergeyBiryukov
5 years ago

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

#2 @swissspidy
5 years ago

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

@MikeHansenMe
5 years ago

#3 @MikeHansenMe
5 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
5 years ago

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

@MikeHansenMe
5 years ago

use $post instead of $id

#5 @ocean90
5 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.