the_content() and more link

View: New views
5 Messages — Rating Filter:   Alert me  

the_content() and more link

by James Davis-6 :: Rate this Message:

| View Threaded | Show Only this Message

I'm currently using the following code in a theme.

<?php the_content('Continue reading "'. the_title("","",false).'"'); ?>

It outputs something like

blah blah blah content blah blah blah
<p><a href="linktomore">Continue reading</a></p>

Is there a way to avoid these paragraph tags and instead output
something similar to

blah blah blah content blah blah blah
<a href="linktomore">Continue reading</a>

Thanks,

James

--
http://www.freecharity.org.uk/ - Free IT services for charities
http://www.freecharity.org.uk/wiki/ - The VCSWiki
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: the_content() and more link

by Computer Guru :: Rate this Message:

| View Threaded | Show Only this Message

<?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).'"'));

?>

On 5/31/07, James Davis <james@...> wrote:

> I'm currently using the following code in a theme.
>
> <?php the_content('Continue reading "'. the_title("","",false).'"'); ?>
>
> It outputs something like
>
> blah blah blah content blah blah blah
> <p><a href="linktomore">Continue reading</a></p>
>
> Is there a way to avoid these paragraph tags and instead output
> something similar to
>
> blah blah blah content blah blah blah
> <a href="linktomore">Continue reading</a>
>
> Thanks,
>
> James
>
> --
> http://www.freecharity.org.uk/ - Free IT services for charities
> http://www.freecharity.org.uk/wiki/ - The VCSWiki
> _______________________________________________
> wp-hackers mailing list
> wp-hackers@...
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


--
Computer Guru
Founder
NeoSmart Technologies
http://neosmart.net/blog/
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: the_content() and more link

by James Davis-6 :: Rate this Message:

| View Threaded | Show Only this Message

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

--
http://www.freecharity.org.uk/ - Free IT services for charities
http://www.freecharity.org.uk/wiki/ - The VCSWiki
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: the_content() and more link

by Robin Adrianse-2 :: Rate this Message:

| View Threaded | Show Only this Message

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@...> 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
>
> --
> http://www.freecharity.org.uk/ - Free IT services for charities
> http://www.freecharity.org.uk/wiki/ - The VCSWiki
> _______________________________________________
> wp-hackers mailing list
> wp-hackers@...
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: the_content() and more link

by Computer Guru :: Rate this Message:

| View Threaded | Show Only this Message

-----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@...> 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-----
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers