Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
WordPress Filter content_save_pre
* The content_save_pre filter takes the data posted in the content window and allows for it to be edited
// Generic code to run the filter
add_filter( 'content_save_pre', 'custom_content_save_pre' );
function custom_content_save_pre( $post_content ) {
// $post_content is what was posted to the edit form
// Edit it as needed then return it back to WordPress
return $post_content;
// Code used to save all $_POST info to the content area if the case-studies post type was saved
add_filter( 'content_save_pre', 'pjiag_content_save_pre' );
function pjiag_content_save_pre( $post_content ) {
if( $_POST['post_type'] == 'case-studies' ) :
$content = '';
foreach( $_POST as $k => $v ) :
$content.= $v . ' ';
return $content;
return $post_content;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment