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 want to get the page content (so i can parse the tags/short-codes in it), but i don't want to output the result itself to the browser (i.e. echo=0).

I tried get_the_content(); but its the same deal.

share|improve this question
    
get_the_content() does not echo output, it is returned. So what exactly is your problem with it? –  Rarst Jul 14 '11 at 16:32
    
It doesn't eval the shortcodes in the content. –  Anonymous Jul 14 '11 at 16:35
add comment

2 Answers

up vote 1 down vote accepted

Where are you doing your code parsing? If you're doing it directly in the template file, inside the Loop, then you should be using get_the_content().

However, it might be more efficient to filter the_content(), via the the_content filter. e.g. in functions.php:

function mytheme_filter_the_content( $content ) {
    // add code here to filter the_content
    // which is contained in the $content variable,
    // then return $content
    return $content;
}
add_filter( 'the_content', 'mytheme_filter_the_content' );

EDIT

If, for whatever reason, you just want to parse the_content(), pull out the shorcodes, and execute them, use do_shortcode() (Codex ref). e.g.:

<?php
$page_content = get_the_content();
$page_shortcodes = array() // ...some array that includes whatever shortcodes you found

foreach ( $page_shortcodes as $page_shortcode ) {
    do_shortcode( $page_shortcode );
}
?>
share|improve this answer
    
Im using a template file, but i just want to get the page content and eval the short-codes in the page, without generating the HTML. –  Anonymous Jul 14 '11 at 16:32
    
See updated answer. –  Chip Bennett Jul 14 '11 at 16:39
    
Thank you works perfect. –  Anonymous Jul 14 '11 at 16:50
add comment

You can try this :

$page_data = get_page( $page_id ); 
$page_content = $page_data->post_content;
share|improve this answer
    
I can get it that's not the problem, the problem is evaluating the short-tags. This just get the plain text. –  Anonymous Jul 14 '11 at 16:26
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.