add only extract and 1 picture – I keep failing – please help
-
Hi!
I have finally the below working code to send an email once my post is published, but I died trying to add a modification to change it from full post to FILTER only Excerpt of X length (Excerpt box is empty) and pick up the thumbnail or the 1st image of that post. Would you please tell what is the correct code for that? I spent 5 hours trying all kinds of combinations and failed miserably.Thank you so much!
<?php
function send_email($post_ID) {
$FromEmail = “[email protected]”;
$to = “[email protected]”;
$mypost = get_post($post_ID);
$subject = $mypost->post_title;
$body = $mypost->post_content;
$headers = “MIME-Version: 1.0” . “\r\n”;
$headers .= “Content-type:text/html;charset=iso-8859-1” . “\r\n”;
$headers .= “From: \”$FromEmail\” <$FromEmail>\n”;
@wp_mail($to, $subject, $body, $headers);
}add_action(‘publish_post’,’send_email’);
?>
- The topic ‘add only extract and 1 picture – I keep failing – please help’ is closed to new replies.