Skip to content

Instantly share code, notes, and snippets.

@robincornett
Created April 12, 2016 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robincornett/d5cc3c225de4bf04924bfca718f66f89 to your computer and use it in GitHub Desktop.
Save robincornett/d5cc3c225de4bf04924bfca718f66f89 to your computer and use it in GitHub Desktop.
Add a CTA (Call to Action) button to your MailChimp RSS emails.
<?php
// do not include the opening tag
// Disable the Read More link added by Send Images to RSS
add_filter( 'send_images_rss_excerpt_read_more', '__return_false' );
<?php
// do not include the opening tag
add_filter( 'send_images_rss_excerpt_read_more', 'leaven_change_read_more_cta', 10, 5 );
/**
* Modify the Send Images to RSS excerpt "read more" link output to be a button in MailChimp.
*
* @author Robin Cornett
*
* @param $output string final output for "read more" text
* @param $read_more string "read more" text set on plugin settings page
* @param $blog_name string the name of your site
* @param $post_name string the post name
* @param $permalink string URL for the post
*
* @return string
*/
function leaven_change_read_more_cta( $output, $read_more, $blog_name, $post_name, $permalink ) {
// set your colors here
$button_color = '#2a717a';
$link_color = '#ffffff';
// for a full width button using your Read More text, you shouldn't need to change this
$output = '<table border="0" cellpadding="0" cellspacing="0" style="background-color:' . $button_color . '; border-radius:5px;" width="100%">';
$output .= '<tbody>';
$output .= '<tr>';
$output .= '<td align="center" style="color:' . $link_color . '; font-weight:bold; line-height:1.5; padding-top:15px; padding-right:30px; padding-bottom:15px; padding-left:30px; margin: 24px auto;" valign="middle"><a href="' . $permalink . '" style="color:' . $link_color . '; text-decoration:none;" target="_blank">' . $read_more . '</a></td>';
$output .= '</tr>';
$output .= '</tbody>';
$output .= '</table>';
return $output;
}
*|RSSITEMS:|*
<h2 class="mc-toc-title"><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></h2>
*|RSSITEM:CONTENT|*
<table border="0" cellpadding="0" cellspacing="0" style="background-color:#2a717a; border-radius:5px;" width="100%">
<tbody>
<tr>
<td align="center" style="color:#FFFFFF; font-weight:bold; line-height:150%; padding-top:15px; padding-right:30px; padding-bottom:15px; padding-left:30px; margin: 24px auto;" valign="middle"><a href="*|RSSITEM:URL|*" style="color:#FFFFFF; text-decoration:none;" target="_blank">Read *|RSSITEM:TITLE|* on my site.</a></td>
</tr>
</tbody>
</table>
*|END:RSSITEMS|*
*|RSSITEMS:|*
<h2 class="mc-toc-title"><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></h2>
*|RSSITEM:CONTENT|* *|END:RSSITEMS|*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment