Viewing 5 replies - 1 through 5 (of 5 total)
  • 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

    (@thervgeeks)

    Thanks, backbone. I’ll give that a shot!

    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

    (@thervgeeks)

    PHP is not my area of expertise, either… so I definitely appreciate the additional info! Thanks!

    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

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

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