WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 months ago

#17993 closed feature request (wontfix)

the_content vs get_the_content

Reported by: merlinox Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2
Component: Template Keywords: close 2nd-opinion
Focuses: Cc:

Description

Wordpress lacks of a main function: obtain full formatted "content" without echo! Maybe good to add a param to the_content() like echo(bool)?

I wrote it:

function the_content_noecho($more_link_text = null, $stripteaser = 0) {
       $content = get_the_content($more_link_text, $stripteaser);
       $content = apply_filters('the_content', $content);
       $content = str_replace(']]>', ']]>', $content);
       return $content;
   }

Change History (4)

comment:1 SergeyBiryukov3 years ago

  • Keywords close 2nd-opinion added

I don't think we need a wrapper for something that can be done with a couple of lines and is documented in Codex: http://codex.wordpress.org/Function_Reference/the_content#Alternative_Usage

Suggest wontfix.

Last edited 19 months ago by SergeyBiryukov (previous) (diff)

comment:2 mdgl19 months ago

The problem is that those 3 lines have to be replicated in literally thousands of plugins/themes! This is wasteful and error prone as well as creating even more fragile dependencies between those plugins/themes and core.

If WP wants to be a grown-up CMS, I would argue that it really needs a simple, obvious and foolproof way for extensions to obtain important things like "the_content" and "the_excerpt" that include all of the processing that WP intends to be applied (e.g. wpautop, texturize and so on). Of course these also need to be easily and *predictably* customisable by themes/plugins where necessary.

We have dozens of related tickets that would benefit from some simplicity and consistency here. In my humble opinion, WP would benefit greatly from a serious look at "hardening" the API between themes/plugins and core in this way. It's not bad, but becoming increasingly fragile and I think in need of a bit of love and attention!

comment:3 avryl8 months ago

  • Component changed from Formatting to Template

comment:4 helen3 months ago

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

No huge demand, and I agree with Sergey.

Note: See TracTickets for help on using tickets.