Title: Additional Template Codes
Last modified: August 30, 2016

---

# Additional Template Codes

 *  [TheRVgeeks](https://wordpress.org/support/users/thervgeeks/)
 * (@thervgeeks)
 * [10 years, 10 months ago](https://wordpress.org/support/topic/additional-template-codes/)
 * Does anyone know if there are any more codes than the ” *|MC:SUBJECT|*” code 
   for inserting WP post data into the Mailchimp Template? I’d really love to have
   access to the Featured Image to be inserted into the Mailchimp Template.
 * Any ideas?
 * Thanks!
 * [https://wordpress.org/plugins/autochimp/](https://wordpress.org/plugins/autochimp/)

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [backbone](https://wordpress.org/support/users/backbone/)
 * (@backbone)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/additional-template-codes/#post-6329186)
 * To add Featured image to the email:
 *     ```
       // Include Featured Image post
       if ( has_post_thumbnail( $postID ) )
       {
       	$postthumbnail = '<div style="float:left;margin-top:5px;margin-right:15px;margin-bottom:9px;">'. get_the_post_thumbnail( $postID,'thumbnail' ) .'</div>';
       }
       ```
   
 * Then insert the variable where you want it to appear in the post content. My 
   example is
 *     ```
       $content[$htmlContentTag] = '<h1 class="h1"><a style="color:#ed0c06;text-decoration:none;" href="' . $permalink . '">' . $posttitle . '</a></h1><p>' .  $postauthors . '</p><p style="margin-top:15px;padding-top:10px;">' . $postthumbnail . $postContent . '</p>';
       ```
   
 * The editing for content to be sent happens at the Autochimp plugin level. I also
   added code to send the Author(s) (includes multiple authors using CoAuthor Plus
   plugin), Categories, & Tag data as well as the inline style markup.
 * This is my edit for the $postContent variable:
 *     ```
       $postContent = wp_trim_words( $post->post_content, 100, ' [...]<div style="display:block;text-align:center;width:100%;margin-top:15px;margin-bottom:25px;padding-top:15px;padding-bottom:25px;"><a style="padding-top:15px;padding-right:25px;padding-bottom:15px;padding-left:25px;color:#ffffff;background-color:#ed0c06;" href="' . $permalink . '"><strong>Read the full post here &raquo;</strong></a></div><div><p>' . $postdate . $postcategories . $posttags . '</p></div>');
       ```
   
 * You will want to make your edits in this section of autochimp.php file:
 *     ```
       function AC_CreateCampaignFromPost( $api, $postID, $listID, $interestGroupName, $categoryTemplateID )
       {...
       }
       ```
   
 *  Thread Starter [TheRVgeeks](https://wordpress.org/support/users/thervgeeks/)
 * (@thervgeeks)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/additional-template-codes/#post-6329187)
 * Thanks, backbone. I’ll give that a shot!
 *  [backbone](https://wordpress.org/support/users/backbone/)
 * (@backbone)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/additional-template-codes/#post-6329188)
 * I’m assuming that you know the $posttitles, $posttags, $postcatergories, $postauthors,
   $postdates are custom variables that have additional code written to perform 
   the function and you have some understanding of php and how to write those codes.
 * PHP is not my area of expertise, self-taught. But this is the basics for those
   variables:
 *     ```
       $posttitle = $post->post_title;
       $postdate = mysql2date( 'F j, Y', $post->post_date );
       $permalink = get_permalink( $postID );
       ```
   
 * This is the basic foreach loop to get the post tags.
 *     ```
       // If post has tags
       $posttagslink = "";
       $posttagsall = get_the_tags( $postID );
       if ( $posttagsall )
       {
       	foreach($posttagsall as $tag)
       	{
       		$taglink = get_tag_link( $tag->term_id );
       		$posttagslink .= '<a href="' . $taglink  . '">' . $tag->name . '</a>, ';
       	}
       	$posttagslinks  = rtrim( $posttagslink, ', ' );
       	$posttags = " | Tagged with: " . $posttagslinks;
       }
       ```
   
 * This is the basic foreach loop to get the post categories.
 *     ```
       // If post has categories
       $postcategorieslinks = "";
       $postcategoriesall = get_the_category( $postID );
       if ( $postcategoriesall)
       {
       	foreach($postcategoriesall as $cat)
       	{
       		$catlink = get_category_link( $cat->term_id );
       		$postcategorieslinks .= '<a href="' . $catlink . '">' . $cat->name . '</a>, ';
       	}
       	$postcatlinks  = rtrim( $postcategorieslinks, ', ' );
       	$postcategories = " | Posted in: " . $postcatlinks;
       }
       ```
   
 * This is the code for single author environment
 *     ```
       $postauthorsID = $post->post_author;
       $postauthorname = get_the_author_meta( 'display_name', $postauthorsID );
       $postauthors = 'by <a href="'. get_author_posts_url( $postauthorsID ) . '">' . $postauthorname . '</a>';
       ```
   
 * Hopefully this can give you some direction and you can modify it to your particular
   needs. Good luck!
 *  Thread Starter [TheRVgeeks](https://wordpress.org/support/users/thervgeeks/)
 * (@thervgeeks)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/additional-template-codes/#post-6329189)
 * PHP is not my area of expertise, either… so I definitely appreciate the additional
   info! Thanks!
 *  [chrisbelote](https://wordpress.org/support/users/chrisbelote/)
 * (@chrisbelote)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/additional-template-codes/#post-6329195)
 * Hey backbone, thanks for all the great info and help!! YOU THE MAN!
 * I used all of the code mentioned above and everything works perfectly.
 * I think I might be missing something with on thing, though. On the top of the
   post where it is supposed to show the author info, it just says “by” with nothing
   else. Any ideas? (see the image/link below.)
 * [https://snag.gy/yOptwu.jpg](https://snag.gy/yOptwu.jpg)

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Additional Template Codes’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/autochimp_3e7b83.svg)
 * [AutoChimp](https://wordpress.org/plugins/autochimp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/autochimp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/autochimp/)
 * [Active Topics](https://wordpress.org/support/plugin/autochimp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/autochimp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/autochimp/reviews/)

 * 5 replies
 * 3 participants
 * Last reply from: [chrisbelote](https://wordpress.org/support/users/chrisbelote/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/additional-template-codes/#post-6329195)
 * Status: not resolved