[wp-hackers] the_content() and more link
Computer Guru
computerguru at neosmart.net
Sat Jun 2 07:29:48 GMT 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Robin Adrianse wrote:
> Yeah, the_content() echoes and doesn't return.
>
> You would want apply_filters( 'the_content', get_the_content() ).
>
> On 6/1/07, James Davis <james at freecharity.org.uk> wrote:
>>
>> Computer Guru wrote:
>> > <?php
>> >
>> > $text = preg_replace('/(.+)<p><a href="([^"]+)">Continue
>> > reading<\/a><\/p>/i', '\\1<a href="\\2">Continue reading</a>',
>> > the_content('Continue reading "'. the_title("","",false).'"'));
>> >
>> > ?>
>>
>> Perhaps I'm being silly but that doesn't appear to work because
>> the_content prints output and doesn't return it where it could be used
>> as an input to $text.
>>
>> James
That is true, of course.
This will instead output (return) the content, just grabbed the code
from my CompleteRSS plugin:
<?php
function NST_get_the_content()
{
global $post;
// Password checking copied from get_the_content()
if ( !empty( $post->post_password ) )
if ( stripslashes( $_COOKIE['wp-postpass_'.COOKIEHASH] ) !=
$post->post_password )
return get_the_password_form();
return $post->post_content;
}
function NST_return_content()
{
$content = NST_get_the_content();
$content = apply_filters( 'the_content', $content );
$content = str_replace(']]>', ']]>', $content);
return $content;
}
?>
- --
Computer Guru
NeoSmart Technologies
http://neosmart.net/blog/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.3 (GNU/Linux)
iD8DBQFGYRxs3SICh4XKUt0RAgBuAKCMKeR+F5XnejofUN5xlFzsR8X0oACfcjfF
QEFYhAeebkGI1fYGmRgGK9I=
=f4U9
-----END PGP SIGNATURE-----
More information about the wp-hackers
mailing list