• I’m working with the wp-email plugin and having some problems. I’m trying to change it to send just an excerpt instead of the whole post.

    By default, the plugin uses $post_content to fill in the content of the email. I’m trying to substitute in $post_excerpt. It works only if I have an excerpt filled in for the post. It won’t take just the first 120 characters or whatever of the post like I assume it would. Can anybody help me get the excerpt?

    This looks like the important parts of the code…

    // Assign Variables
    $post = $wpdb->get_row("SELECT post_name, post_date, post_title, post_excerpt, post_author FROM wp_posts WHERE ID = '$p' AND post_status = 'publish' AND post_password = ''");
    $post_id = (int) $post->ID;
    $post_title = htmlspecialchars(stripslashes($post->post_title));
    $post_date = mysql2date('j F Y', $post->post_date);
    $post_excerpt = wpautop(stripslashes($post->post_excerpt));
    $post_alt_content = htmlspecialchars(stripslashes($post->post_excerpt));
    $post_author = htmlspecialchars(stripslashes($post->post_author));

    // Mail Failed Because Of Empty Fields
    if(empty($yourname) || empty($youremail) || empty($friendname) || empty($friendemail) || empty($post)) {
    echo '<p>';
    echo '<b>Error</b><br />';
    echo '<b>&raquo;</b> Some Fields Are Not Filled In<br />';
    echo '<b>&raquo;</b> This Is A Private Post<br />';
    echo '</p>';
    echo '<p><a href="javascript:history.go(-1);">Click Here To Go Back</a></p>';
    exit();
    }

    // Assign Text
    $mail_body = "<p>This page was sent to you by $youremail</p><p><strong>Message:</strong><br />$yourremarks</p><p><strong><a href=".get_permalink().">$post_title</a></strong> | $post_date<br />$post_excerpt<br /><br /><a href=".get_permalink().">".get_permalink()."</a></p>

    <p>&nbsp</p><p>Article taken from ".get_bloginfo('name')." - ".get_bloginfo('url')."</p><p>URL to article: ".get_permalink()."</p>";

  • The topic ‘trying to get default excerpt with $post_excerpt’ is closed to new replies.