Custom Services feed for Mailchimp Newsletter

By Heather Chen
June 2, 2019, 8:43 pm EDT

Following up on this item from a couple of years ago: (https://www.uua.org/communications/websites/forum/content/services-mailchimp-newsletter)

We've been wanting to use mailchimp for newsletters, but the services feed wasn't suitable because the service feed posts were ordered by the wordpress published date and I was not able to figure out how to retrieve only the upcoming services without manually manipulating the wordpress service post published date. So, I have created a custom feed for upcoming services that includes only future dated uua_services posts in ascending order by Service Date.

I'm a newbie to php and wordpress, so it isn't very full featured, but it does retrieve upcoming services and is usable in a mailchimp to bring in the title, content, featured image, the pretty service date.

It allows us to use mailchimp for a weekly newsletter which pulls in only the next service (like this) or a monthly newsletter which pulls in the upcoming services for several weeks (like this).

Here's a link to the feed file on github: https://github.com/uucpa/rainbow-child/blob/master/feeds/feed-upcomingservices.php. I've currently got it configured on our site by putting it in a feeds/ directory under our child theme folder. Then there is a bit of code to add to the functions.php also in the child theme.

/* New Feed containing the upcoming services */
function the_upcoming_service_feed() {
add_feed('upcomingservices', 'upcoming_services_feed');
}
add_action('init', 'the_upcoming_service_feed');
function upcoming_services_feed() {
add_filter('pre_option_rss_use_excerpt', '__return_zero');
//Use get_stylesheet_directory to find the child theme folder. Use get_template_directory() for the parent theme.
load_template( get_stylesheet_directory() . '/feeds/feed-upcomingservices.php' );
}

The feed URL is <site url>/feed/upcomingservices (but note that you have to click save on your settings/permalinks page before it will become visible).

I wonder if it would be possible to eventually get something like this built-in to the uua services plug-in?