How to retrieve text only from wp_content() not from wp_excerpt()?

I’m currently developing a website with WordPress 3.5 and I need to retrieve Post Text (Only text, not include images) at Archive Page. I can retrieve it with wp_excerpt() method without any problems. But the main problem for me is that I can’t get the exact text layout. wp_excerpt() method returns text which ignores all extra spaces and line breaks. What should I do? I think I will get Only Post Text with Exact Layout if I can retrieve from wp_content() method. Thanks in advance for your help!

5

Or even simpler:

echo wp_strip_all_tags( get_the_content() );

By using:

  • get_the_content()

    Retrieve the post content. (Must be used in a Loop)

    An important difference from the_content() is that get_the_content() does not pass the content through the ‘the_content‘. This means that get_the_content() will not auto-embed videos or expand shortcodes, among other things.

  • wp_strip_all_tags()

    Properly strip all HTML tags including script and style.

Leave a Comment