Skip to content

@jeffreyzinn /content_save_pre.php
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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 . ' ';
endforeach;
return $content;
endif;
return $post_content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.