Opened 23 months ago
Last modified 8 months ago
#17993 new feature request
the_content vs get_the_content
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Formatting | Version: | 3.2 |
| Severity: | normal | Keywords: | close 2nd-opinion |
| 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 (2)
comment:1
SergeyBiryukov — 21 months ago
- Keywords close 2nd-opinion added
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!

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.