Email posts to subscribers First post image/thumbnail
-
Hello!
I’m a newbie in this forum and my English isn`t that good. Sorry.
Basic informations:
I use the TwentyEleven Theme.
Plugin: Email posts to subscribersI want to make a newsletter with the last 5 posts.
But I want to use the first image of the post and not the thumbnail for the list.
How can I change that?MySide: http://www.qualityinmotion.at/blog
Code of the Plugin:
<?php if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) { die('You are not allowed to call this page directly.'); } ?> <?php class elp_cls_newsletter { public static function elp_template_compose($id = 0, $post = 5, $cat = "", $orderby = "", $order = "DESC", $action = "preview") { $excerpt_length = 50; // Change this value to increase the content length in newsletter. global $wpdb; $prefix = $wpdb->prefix; $preview = ""; $arrRes = array(); $sSql = "SELECT * FROM <code>".$prefix."elp_templatetable</code> where 1=1"; $sSql = $sSql . " and elp_templ_id=".$id; $arrRes = $wpdb->get_row($sSql, ARRAY_A); if(count($arrRes) > 0) { $elp_templ_heading = stripslashes($arrRes['elp_templ_heading']); $elp_templ_header = stripslashes($arrRes['elp_templ_header']); $elp_templ_body = stripslashes($arrRes['elp_templ_body']); $elp_templ_footer = stripslashes($arrRes['elp_templ_footer']); $elp_templ_status = $arrRes['elp_templ_status']; $replacefrom = array("<ul><br />", "</ul><br />", "<li><br />", "</li><br />", "<ol><br />", "</ol><br />", "</h2><br />", "</h1><br />", "</h3><br />"); $replaceto = array("<ul>", "</ul>", "<li>" ,"</li>", "<ol>", "</ol>", "</h2>", "</h1>", "</h3>"); $replacefrom1 = array("<ul><br />", "</ul><br />", "<li><br />", "</li><br />", "<ol><br />", "</ol><br />", "</h2><br />", "</h1><br />", "</h3><br />", "<br />"); $replaceto1 = array("<ul>", "</ul>", "<li>" ,"</li>", "<ol>", "</ol>", "</h2>", "</h1>", "</h3>", ""); //$preview = "<html>"; //$preview = $preview . "<head><title>" . $elp_templ_heading . "</title></head>"; //$preview = $preview . "<body>"; $preview = $preview . '<div style="clear:both;"></div>'; $preview = $preview . $elp_templ_header; $preview = $preview . '<div style="clear:both;"></div>'; //----------------------------------------------------------- $body = $elp_templ_body; $post_id = ""; $post_title = ""; $post_excerpt = ""; $post_link = ""; $post_thumbnail = ""; $post_thumbnail_link = ""; $post_date = ""; $post_author = ""; $i = 1; $qstring = "posts_per_page=".$post."&post_status=publish&category='".$cat."'&orderby='".$orderby."'&order='".$order."'"; $postlist = get_posts( $qstring ); $posts = array(); foreach ( $postlist as $post ) { setup_postdata($post); $post_id = $post->ID; $post_title = $post->post_title; $post_author = get_the_author(); $post_date = $post->post_modified; $post_category = $post->category; // Get full post $post_full = $post->post_content; $post_full = str_replace($replacefrom, $replaceto, $post_full); $post_full = str_replace($replacefrom1, $replaceto1, $post_full); $post_full = wpautop($post_full); $post_excerpt = elp_cls_newsletter::elp_excerpt_by_id($post_id, $excerpt_length); $post_excerpt = wpautop($post_excerpt); $post_link = get_permalink($post_id); if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail($post_id))) { $post_thumbnail = get_the_post_thumbnail($post_id, 'thumbnail'); } if($post_thumbnail <> "") { $post_thumbnail_link = "<a href='".$post_link."' target='_blank'>". $post_thumbnail_link."</a>"; } if($post_title <> "") { $post_title = "<a href='".$post_link."' target='_blank' style=''>".$post_title."</a>"; } $bodyown = str_replace('###POSTTITLE###', $post_title, $body); $bodyown = str_replace('###POSTIMAGE###', $post_thumbnail_link, $bodyown); $bodyown = str_replace('###POSTDESC###', $post_excerpt, $bodyown); $bodyown = str_replace('###POSTFULL###', $post_full, $bodyown); $bodyown = str_replace('###DATE###', $post_date, $bodyown); $bodyown = str_replace('###AUTHOR###', $post_author, $bodyown); //$preview = $preview . '<div style="clear:both;"></div>'; $preview = $preview . $bodyown; $preview = $preview . '<div style="clear:both;"></div>'; $post_id = ""; $post_title = ""; $post_excerpt = ""; $post_link = ""; $post_thumbnail = ""; $post_thumbnail_link = ""; $post_date = ""; $post_author = ""; $i = $i + 1; } wp_reset_postdata(); wp_reset_query(); //----------------------------------------------------------- $preview = $preview . '<div style="clear:both;"></div>'; $preview = $preview . $elp_templ_footer; $preview = $preview . '<div style="clear:both;"></div>'; if($action == "preview") { $preview = str_replace('###EMAIL###', "useremail@email.com", $preview); $preview = str_replace('###NAME###', "User Name", $preview); } //$preview = $preview . "<body>"; //$preview = $preview . "</html>"; $preview = str_replace("\r\n", "<br />", $preview); } $preview = str_replace($replacefrom, $replaceto, $preview); $preview = str_replace($replacefrom1, $replaceto1, $preview); return $preview; } public static function elp_excerpt_by_id($post_id, $excerpt_length) { $the_post = get_post($post_id); $the_excerpt = $the_post->post_content; $the_excerpt = strip_tags(strip_shortcodes($the_excerpt)); $words = explode(' ', $the_excerpt, $excerpt_length + 1); if(count($words) > $excerpt_length) { array_pop($words); array_push($words, '...'); $the_excerpt = implode(' ', $words); } $the_excerpt = nl2br($the_excerpt); $the_excerpt = str_replace("<br />", " ", $the_excerpt); $the_excerpt = str_replace("<br />", " ", $the_excerpt); $the_excerpt = str_replace("\r\n", " ", $the_excerpt); return $the_excerpt; } } ?>
If I forgot some needed information, please tell.
Thanks, Valerie
- The topic ‘Email posts to subscribers First post image/thumbnail’ is closed to new replies.