Save custom Excerp to Meta
-
Hey,
i trying to create a own custom excerp and save the value to the Meta of the post. My Goal overall is to save the first h2 to the meta and attach a dot to it.
For the beginning i’m trying to save the auto excerp of wordpress to the meta without any filtering. But for some reason this field stays empty if i save the post. I hope that someone could tell me whats wrong with the script (functions.php).
add_action( 'save_post', 'h2_excerpt_save' ); function h2_excerpt_save( $post_id ) { if ( $_POST['post_type'] == 'post' ) { add_post_meta($post_id, 'h2_excerpt_field', get_the_excerpt($post_id), true); } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Save custom Excerp to Meta’ is closed to new replies.