[wp-hackers] Stopping recursion with save_post/wp_insert_post action

Otto otto at ottodestruct.com
Sat Aug 21 03:51:05 UTC 2010


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> 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
>


More information about the wp-hackers mailing list