Make WordPress Core

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#40908 closed defect (bug) (invalid)

HTML Paragraph Tags are omitted in the return value of get_the_content().

Reported by: digitronixweb's profile digitronixweb Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords:
Focuses: template Cc:



I noticed a minor bug regarding the default Wordpress Post & Page content field.

When getting the value of the default Wordpress content WYSIWYG field using the following snippet:


if(have_posts()) { 
    while(have_posts()) {

The correct HTML formatting is output as expected.

If instead I use the following:


if(have_posts()) { 
    while(have_posts()) {
       echo get_the_content();

HTML tags persist in the resulting value, however, paragraph tags are seemingly omitted from the value return from the call to get_the_content.


Change History (2)

#1 @ocean90
7 years ago

  • Component changed from Editor to Posts, Post Types
  • Focuses ui administration removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed
  • Version 4.7.5 deleted

Hello @digitronixweb, welcome to WordPress Trac!

get_the_content() is not a direct replacement for the_content(). Adding paragraphs to the content is handled by the the_content filter which only exists in the_content().

To get the same content as the_content() you have to use apply_filters( 'the_content', get_the_content() ).

#2 @digitronixweb
7 years ago

Ah I see, my apologies!

Thanks for the quick feedback, it's really appreciated!

Note: See TracTickets for help on using tickets.