wordpress post / page save and see

After a few hours of searching on the internet I finally assembled the hooks and actions necessary to add a new button to the save meta box for worpdress posts and pages. What I needed was a button that saves my work on a post edit page, and redirects to view the post .  here is the code for your functions.php file or plugin, change title in both functions for your own language preference. Hey who's making the plugin ?


add_action('post_submitbox_misc_actions', 'save_and_see_button');
function save_and_see_button()
    //global $post;
    echo '<div id="send-for-correction" class="misc-pub-section"
    style="border-top-style:solid; border-top-width:1px; border-top-color:#EEEEEE; border-bottom-width:0px;">
    <input id="save-post2" class="button button-highlighted"
    type="submit" value="MAJ + voir" name="save">
}add_filter( 'redirect_post_location' , 'my_filter_handler'   );
function my_filter_handler( $location  )
    global $post;
    if (  ($_POST['save'])== "MAJ + voir" &&  preg_match("/post=([0-9]*)/", $location, $match) &&
        $post &&
        $post->ID == $match[1] &&
        (isset($_POST['publish']) || $post->post_status == 'publish') && // Publishing draft or updating published post
        $pl = get_permalink($post->ID)
    ) {
        // Always redirect to the post
        $location = $pl;

     return $location;
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *