I'm new to WP but not PHP.

I've a custom page that I have a PHP call to do some processing on the page content.

the_content() even when enclosed in a function call

<?php do_something(the_content()  ); ?>

echos the page content.

How do I get the page data without so I can send it to a php function?

1 Answer 1


the_content does echo the content. That is stated in the Codex-- "Displays the contents of the current post", emphasis mine. Use get_the_content instead, to return a string that you can manipulate.

Be aware that get_the_content does not run all of the same filter as the_content. Again from the Codex:

If you use plugins that filter content (add_filter('the_content')), then this will not apply the filters, unless you call it this way (using apply_filters):

<?php apply_filters('the_content',get_the_content( $more_link_text,> $stripteaser, $more_file )) ?>
  • Perfect many thanks. I'm finding getting to grips with the lexian used is the hard bit with WP.
    – dave C
    May 14, 2013 at 18:11
  • Frequently, the_ echoes, get_ returns a string, but I think there are exceptions.
    – s_ha_dum
    May 14, 2013 at 18:21
  • @s_ha_dum I find the tricky part is remembering when it's get_the_ vs. just get_ (like get_the_content() or get_permalink()).
    – Pat J
    May 14, 2013 at 19:39
  • @PatJ : Yes, I know. get_permalink gets me all the time.
    – s_ha_dum
    May 14, 2013 at 19:46

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.