Trying to save a post

Adding a save post is making saving post a difficult endevour.

I was trying to add a post in my calendar plugin. Saving multiple posts in one post. But what i didn`t think about is when the save_post was triggered. Now if i saves a item i triggered the event, but when i triggered the event i triggered it again. So in stead of savin one item i now am on item 2530 in stead of 23. That`s 2500 plus items i saved not wating to save, and my calender was filled with items.

If you trigger an event in a meta box and you want to use the¬†add_action(‘save_post’, ‘my_function’) to use the wp_insert_post event, use the¬†remove_action(‘save_post’, ‘my_function’) bevore it. Else you will be saving a lot of duplicates.

Geef een reactie

Jouw e-mailadres wordt niet gepubliceerd. Verplichte velden zijn gemarkeerd met *