1

I'm wanting to use the MailChimp RSS to Email Campaign mechanism to send a weekly email of posts to list subscribers.

This works just fine in standard use, but the twist is that I don't want MailChimp to only pick up new posts. Each week I want it to include all posts in the Newsletter category - regardless of whether it included them in last week's email (some announcements should run for several weeks).

Is there a way to reset the posts so that they appear new to the RSS feed each week?

Many thanks!

1

Here's one idea how we could get a full control over our newsletter feed:

Feed with custom posts selection and drag/drop ordering:

We can use the navigational menu UI, to select exactly what posts to display in the feed and sort them with drag/drop.

We need to follow these two steps:

Step 1) Create a menu with the menu name newsletter under the /wp-admin/nav-menus.php page: :

Select newsletter posts

where we add all the posts, to the menu, that we need to include in the newsletter.

Then we order them as needed with the drag/drop feature of the menu UI.

Step 2) Use the following code snippet:

/**
 * Custom Newsletter Feed
 *
 * Supports drag/drop for feed items.
 *
 * Create a menu with the 'newsletter' menu name and 
 * access the feed at /feed/?wpse_feed=newsletter
 *
 * @see http://wordpress.stackexchange.com/a/186121/26350
 */

add_action( 'pre_get_posts', function( $q )
{
    $menu = 'newsletter'; // Our custom nav menu.

    if(    $q->is_feed()
        && $menu === filter_input( INPUT_GET, 'wpse_feed' )
    ) {
        $q->set( 'post__in', 
            (array) wp_list_pluck( 
                wp_get_nav_menu_items( $menu ), 
                'object_id' 
            ) 
        );
        $q->set( 'orderby',   'post__in' );
        $q->set( 'post_type', 'any'      );

        //-------------------------------------------------
        // Modify the pubDate. 
        // Let the first post be created at midnight 
        // and then add 1 sec for each get_post_time() call
        //--------------------------------------------------
        add_filter( 'get_post_time', function ( $time, $d, $gmt )
        {
            static $count = 0;
            return date( $d, strtotime( 'midnight' ) + $count++ );
        }, 10, 3 );

    }
} );

Here we modify the pubDate to start at midnight, and then we add 1 second for each call to the get_post_time() function. So the posts will all have different pubDate and it will be different from the day before.

Then we can access our custom made newsletter feed at:

http://example.tld/feed/?wpse_feed=newsletter

This could be expanded to support more custom made feeds, but hopefully you can adjust this to your needs.

  • I see how that creates a new newsletter feed with manual control over the posts to be included (and their order), but how does this tell MailChimp that these are new posts and not the same posts it sent out last week (which they are of course)? – Christopher May 4 '15 at 16:33
  • I'm not familiar with the rss->email feature of MailChimp. How does MailChimp define "updated RSS content" between weekly newsletters? So it will not just take the latest posts from the feed each week and put it into the newsletter emails? @Christopher – birgire May 4 '15 at 18:10
  • It only takes posts which are new since the last RSS-to-Email campaign went out, which is what I'm trying to get around, because some posts to be included in the newsletter we might want to have run for several weeks. I want it to take any active post in the newsletter category (so I can just set them to draft when we don't want them to run anymore) and read that as a new item in the RSS feed each week. – Christopher May 6 '15 at 0:10
  • @Christopher I updated the answer with pubDate modifications. Maybe that will be sufficient? – birgire May 6 '15 at 0:51
  • Oh, I think you've got it. Thanks very much. I didn't realize I could just filter the date in the feed! I'll give it a try. – Christopher May 6 '15 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.