[wp-hackers] How To Append Content To A Post?

Raj list at expost.org
Tue Sep 7 16:30:06 UTC 2010


I meant as part of the loop. Suppose I want to insert an advertisement for
posts of a particular category only. How would I do this other than by
receiving the post ID as a part of a filter and then checking if the post
belongs to a particular category?

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Adriaan Pelzer
Sent: Tuesday, September 07, 2010 9:56 PM
To: wp-hackers at lists.automattic.com
Subject: Re: [wp-hackers] How To Append Content To A Post?

This seems to complicate a very simple issue.

Both post id ($post->ID) and post content ($post->post_content) are provided
as attributes of the post object.

To see all of them, just do
print_r ($post);


Adriaan Pelzer
RAAK
putting you in touch with your crowds
http://www.wewillraakyou.com
<http://www.wewillraakyou.com>twitter: http://www.twitter.com/adriaan_pelzer
linkedIn: http://uk.linkedin.com/pub/adriaan-pelzer/4/874/860/
skype: adriaan_pelzer
<http://uk.linkedin.com/pub/adriaan-pelzer/4/874/860/>
+4478 7978 1743



On Tue, Sep 7, 2010 at 5:14 PM, Eric Mann <eric at eamann.com> wrote:

> Not with this filter.  See the codex reference here:
> http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content
>
> If you want both the content *and* the post ID, I recommend editing 
> your loop to append the content instead of using a filter.  Then 
> you'll have access to all of the post's meta information.
>
>
> On September 7, 2010 at 4:11 PM Raj <list at expost.org> wrote:
>
> > Is there anyway of passing the id of the post also?
> >
> > -----Original Message-----
> > From: wp-hackers-bounces at lists.automattic.com
> > [mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of Eric Mann
> > Sent: Tuesday, September 07, 2010 8:43 PM
> > To: wp-hackers at lists.automattic.com
> > Subject: Re: [wp-hackers] How To Append Content To A Post?
> >
> > All post content passes through the 'the_content' filter.  To append
> anything
> > to post content merely requires that you hook into that filter and
append
> your
> > content.
> >
> > For example, the following will append a paragraph element with body
> "this was
> > appended":
> >
> > function my_append_content($content) {
> > $content = $content + "<p>This was appended</p>"; return $content; }
> >  add_filter('the_content', 'my_append_content');   On September 7, 2010
> at
> > 3:01 PM Raj <list at expost.org> wrote:
> >
> > >
> > >
> > > What is the proper method to append some content to a post. Suppose I
> > > want to append a newsletter subscription form or an advertisement to
> > > the end of all posts, what is the best method of doing this?
> > >
> > >
> > >
> > > _______________________________________________
> > > wp-hackers mailing list
> > > wp-hackers at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list