Reputation: 81
I understand that you can hook into the save_post or wp_insert_post actions but I would like to maintain the "Save Draft" functionality but create an additional button that saves the post as well as fires another function. I have not been able to find anything useful. Any help or direction would be welcomed. thanks.
Upvotes: 0
Views: 1397
Reputation: 1287
You can add additional content in the post submit box by hooking in to the post_submitbox_start
action. Here's an example just to show how you add content. You can try pasting this into your functions.php and you will see the button appear in the edit post screen, next to the normal publish button.
function myButton() {
?>
<button>This is a button</button>
<?php
}
add_action("post_submitbox_start", "myButton");
This button doesn't do anything, and it's not styled, but I hope you get the concept.
To give it functionality you could either use it as a submit button for the normal edit form, and hook into save post filters in the backend to add special functionality if submitted with this button. Or you could just add a small script element and give it an onclick callback with javascript instead, if that suits your needs better.
Hope this gets you in the right direction.
Upvotes: 1