[wp-hackers] Stopping recursion with save_post/wp_insert_post action
ProDevStudio
prodevstudio at gmail.com
Sat Aug 21 04:01:06 UTC 2010
I am calling wp_insert_post again to place a media attachment.
I think I found a way... which is to remove the action before calling
wp_insert_post again.
Kind Regards,
Azizur Rahman
On Sat, Aug 21, 2010 at 4:51 AM, Otto <otto at ottodestruct.com> wrote:
> Why are you calling wp_insert_post again?
>
> -Otto
>
>
>
> On Fri, Aug 20, 2010 at 10:27 PM, Azizur Rahman
> <prodevstudio+wordpress at gmail.com <prodevstudio%2Bwordpress at gmail.com>>
> wrote:
> > Hi All,
> >
> > I am writing a plugin that hooks into wp_insert_post action.
> >
> > The problem is that I am going into recursion at the moment and not sure
> how
> > to stop it.
> >
> > Here is the pseudo code logic
> > *********************************************************************
> > on wp_insert_post or save_post
> >
> > check the $post->content for x.
> > return if x is NOT found
> >
> > if x is found do
> > if x does NOT have meta key/value _x_details_ set
> > $x_details_id = wp_insert_post( $x_details);
> > add_post_meta($post_ID, '_x_details_', $x_details_id, true);
> > end
> > *********************************************************************
> > I am sure you can see the recursion I am getting myself into when calling
> > wp_insert_post( $x_details);
> >
> > what is the best way to stop this recursion?
> >
> > Is there a better way of doing this?
> >
> >
> > Thanks in advanced!
> >
> > Kind Regards,
> >
> > Azizur Rahman
> > _______________________________________________
> > 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