3

When using the the_post() loop, how do I fetch the post data? I can't retrieve the post content data with the_content() because it automatically 'prints' the content on the screen.

I need it to be stored in a value so I can manipulate it, I need to display only a small portion of the content for the headlines.

2
  • Have you searched the Wordpress API (the Codex)? Commented Apr 3, 2012 at 17:27
  • 1
    General tip: if you have a wordpress function the_x() that ouputs something, then there's usually a get_the_x() that returns that output instead of outputting it. Commented Apr 3, 2012 at 17:32

3 Answers 3

10

use get_the_content() to get the contents of the post

Sign up to request clarification or add additional context in comments.

Comments

3

See get_the_content() function - http://codex.wordpress.org/Function_Reference/get_the_content

Note the section there on applying filters apply_filters('the_content',...

Comments

-1

Or... just the global var $post

$post->post_content

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.