Skip to content

Instantly share code, notes, and snippets.

@jpen365
Created September 21, 2016 04:59
Show Gist options
  • Save jpen365/e4b775d0834ac3e5c6e6dba939a0ecd9 to your computer and use it in GitHub Desktop.
Save jpen365/e4b775d0834ac3e5c6e6dba939a0ecd9 to your computer and use it in GitHub Desktop.
<?php
/* Save the input to post_meta_data */
function jpen_save_custom_post_order( $post_id ){
if ( !isset( $_POST['jpen_custom_post_order_nonce'] ) || !wp_verify_nonce( $_POST['jpen_custom_post_order_nonce'], basename( __FILE__ ) ) ){
return;
}
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ){
return;
}
if ( ! current_user_can( 'edit_post', $post_id ) ){
return;
}
if ( isset( $_REQUEST['pos'] ) ) {
update_post_meta( $post_id, '_custom_post_order', sanitize_text_field( $_POST['pos'] ) );
}
}
add_action( 'save_post', 'jpen_save_custom_post_order' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment