Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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 )) ?>
share|improve this answer
    
Perfect many thanks. I'm finding getting to grips with the lexian used is the hard bit with WP. –  dave C May 14 '13 at 18:11
    
Frequently, the_ echoes, get_ returns a string, but I think there are exceptions. –  s_ha_dum May 14 '13 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 '13 at 19:39
    
@PatJ : Yes, I know. get_permalink gets me all the time. –  s_ha_dum May 14 '13 at 19:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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