private function email_html_content( $email ){ $args = array( 'posts_per_page' => 5, 'offset' => 0, 'orderby' => 'date', 'order' => 'DESC', ); $posts = get_posts( $args ); $mailTemplate = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/subscribe/template.html'); $postTemplate = file_get_contents($_SERVER['DOCUMENT_ROOT'] . '/subscribe/post.html'); $unsibscribeLink = get_bloginfo('url') . '/?stc_unsubscribe=' . $email['hash'] . '&stc_user=' . $email['email']; $mainPost = current($posts); unset($posts[0]); $latestPosts = ''; foreach($posts as $post) { setup_postdata( $post ); $replace = array( '{post_title}' => $post->post_title, '{post_content}' => strip_tags($this->string_cut($post->post_content,100)), '{post_link}' => get_permalink($post->ID), '{post_picture}' => get_the_post_thumbnail($post->ID,array(140,110)), ); $latestPosts .= strtr($postTemplate, $replace); } setup_postdata( $mainPost ); $replace = array( '{post_title}' => $mainPost->post_title, '{post_date}' => $mainPost->post_post_date, '{post_content}' => strip_tags($this->string_cut($mainPost->post_content,250)), '{post_link}' => get_permalink($mainPost->ID), '{post_picture}' => get_the_post_thumbnail($mainPost->ID,array(625,370)), '{latest_post}' => $latestPosts, '{unsibscribe_link}' => $unsibscribeLink ); echo strtr($mailTemplate, $replace); }