Plugin bug

tweetmyposts

My “tweetmypost” plugin had a bug where every time I edited the same post. It would tweet out as a new post. The problem itself lies with the hook “publish_post”. Publish post is triggered on new posts and updated posts.

The solution is to use 3 other hooks.


add_action('future_to_publish','function_name');
add_action('new_to_publish','function_name');
add_action('draft_to_publish','function_name');

That way, you’ve covered all the possibility of a new post but ignoring the edit post trigger.

Leave a Reply

"Life is like a camera. Focus only on what is important and you will capture it perfectly."