How to: a recent posts plugin for e-Newsletter

A bunch of you have posted over time, asking for a way to include recent posts in your e-Newsletter mailings. In my recent aborted foray into using e-Newsletter for my mailings, I wound up writing a recent posts plugin (code below).

Here's how it works. First, you need the hacked version of e-Newsletter that supports shortcodes from here.

Next, you'll need to cut and paste the code below into a file named something like recent-posts.php in a folder named something like recent-posts, and drop it into your plugins. Then, use the shortcode in the form:

[e-newsletter-recent-posts limit="30"]

You can leave the limit parameter out if you want.

Now, here are the cautions. This code is unsupported and I'm not using it. In fact, as my long discussion about e-Newsletter shows, I've given up on using e-Newsletter and am going back to rolling my own solution (it's ugly, don't ask).

Anyway, the point is, using this plug-in is something you do at your own risk. Using it could cause you to have babies (if you don't want them), or not be able to have them (if you want them). It could knock the world off its axis. It could cause baldness. It could cause your pee to smell. Baaaaaad things could happen. It will not be supported, it will not be updated, it will not solve your problem, it will not get you a date, and it will not make you a happy person. It will not bring about world peace and it will not make the world want to eat its peas.

It is, merely, a slab of barely tested, horribly under-loved code. It is the Pauly Shore of plug-ins.

So, there you go. Good luck. May the farce be with you. Don't blame me if you your wife leaves you, you lose your home, or you become uncontrollably flatulent.

Oh, and I have no idea if it works in multisite or not. I tried it once, found the problem that made me dump e-Newsletter, and went on my merry way. My guess is it works in each site, for that site. But, you won't know until you try it, and don't tell me. My apathy knows no bounds when it comes to this project.

Plugin Name: e-Newsletter Shortcodes
Description: This plug-in provides shortcodes for mailing newsletters for e-Newsletter. This is unsupported, probably won't work, and could make your pee smell.
Version: 0.0.1
Author: David Gewirtz
Plugin URI:
Author URI:
License: GPL2

function e_newsletter_recent_posts_shortcode( $atts ) {
	// Thanks to for hints getting started
	extract( shortcode_atts( array( 'limit' => 5 ), $atts ) );

	$q = new WP_Query( 'posts_per_page=' . $limit );

	$list = '<div class="latestposts">';

	while ( $q->have_posts() ) {
		$list .= '<H3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
		$list .= '<div class="latestspost_content"><p>' . get_the_excerpt() . '</p></div>';


	return $list . '</div>';

add_shortcode( 'e-newsletter-recent-posts', 'e_newsletter_recent_posts_shortcode' );
  • aecnu

    Greetings David,

    Thank you for the code and totally hilarious disclaimer, gotta love it.

    I will bring this code to the attention of the lead developer @Cole and maybe he can work some of it into his new plugin that he has been working on in his spare mind.

    As you mentioned many folks have inquired about this exact feature to be included in the eNewsletter plugin.

    Thank you again for the code, it is certainly appreciated.

    Cheers, Joe

  • Cole

    Hey David,

    Thanks for posting that snippet and your overall thoughts on enewsletter. I've incorporated a new sidebar widget for templates that includes an available recent post section. I've also allowed shortcodes to be properly used when creating content within eNewsletter. I'm in the final stages of releasing a new version and I hope you might have some time to take a peak at it to see if some of the issues were addressed.

    Look forward to getting your input.


  • David

    Hi Cole,

    To be honest, I had to move on to my own (very) hacky solution, which is now working. I wrote a script which exports recent posts, puts those recent posts in a Dropbox folder, and another computer running the old list server I've run since 2003 picks up those posts, combines them with a template, and pumps them out old school.

    I would look at your stuff anyway, but I'm three deadlines and one national election backlogged over the next two weeks, so I'm going to have to pass for now.

    But if you still need input in a few weeks, reach out to me, let me know what you want me to look at, and -- unrelated to my production sites -- I'll take a look just to help you along with this.

    You're also welcome to post specific questions here or directly via email and I'll answer them as best as I can.