Research for Mailchimp to WordPress RSS 

WP RSS info for sorting by category – http://codex.wordpress.org/WordPress_Feeds
Overview of WordPress DB – http://codex.wordpress.org/Database_Description
*Categories are found in wp_terms

Something to note about wordpress RSS, permalinking and default linking URL’s are different… here is an example from argent capital targeting the largecap category by ID

http://argentcapital.simplehelix.com/category/largecap/feed/rss/?amp;feed=rss2

http://www.mailchimp.com/blog/rss-to-email-tutorial/

*by default it will excerpt text, and not include image.
*|RSS:RECENT10|* – controls the number of posts to show.

*there is a RSS merge tag cheat sheet in the editor (small icon top right): http://us1.admin.mailchimp.com/campaigns/wizard/html-template?id=1091665#

Problem is sending a google chart.. since they are made at runtime, they don’t make it. The idea is to cache them , and serve the cached image to the email.

http://groups.google.com/group/google-chart-api/browse_thread/thread/36e5f3d79e0d0481?pli=1

Next problem is getting that image inside the RSS description tags….

The idea is to write my own custom RSS for each category, and merge the metadata into the tags.

Feed Validator (make sure im doing this right) – http://feedvalidator.org/

*when cutting and pasting the RSS code from the largecap RSS into a temp file, I run into 2 errors, one is just the ref to the .rss, but the other… when i save it transforms some of the apostrophes and long dashes into garbage, which in turn pisses off the RSS reader at Mailchimp.

Do I continue down the path of writing my own RSS generator which merges meta data content in the tags? Or do I just have the client duplicate an existing post and replace the pictures?

Create a custom RSS feed for WordPress – http://www.frank-verhoeven.com/create-an-rss-feed-with-wordpress/

So the idea of making my own RSS is working, here’s code adapted from frank verhoeven’s site.. I grab a single instance of the most recent post in the largecap category

$my_query = new WP_Query('category_name=largecap&posts_per_page=1');

$rssItems = array(
	'item_1'=>array(
		'Title'       => $my_query->post->post_title,
		'Link'        => $my_query->post->guid,
		'Author'      => $my_query->post->post_author,
		'Date'        => $my_query->post->post_date,
		'Description' => $my_query->post->post_name,
		'Content'     => $my_query->post->post_content
		)
	);

Now I need to nail down the scope of what will be on these emails, here’s the demo template

http://us1.admin.mailchimp.com/templates/edit?id=116753

*this page has a link to MailChimp live chat: http://server.iad.liveperson.net/hc/s-31286565/cmd/kbresource/kb-5739720031443435136/front_page!PAGETYPE

I’l ask Mailchim live chat if Im missing something, maybe I CAN do custom merge tags for this RSS project…

Transcript from converstation:

Please wait for a site operator to respond.
All operators are currently assisting others. Thanks for your patience. An operator will be with you shortly.
You are now chatting with ‘Ariana’
Your Issue ID for this chat is LTK152037878468X
Ariana: Hello Nate!
Ariana: How can I help you?
Nate: hello
Nate: so i have a question about the RSS merge tags
Nate: can i make a custom one, that will pickup data from a particular tag?
Nate: like for example
Nate: |RSS:MyCoolData|
Nate: would pull the data from my rss field
Ariana: one moment
Nate: thanks
Ariana: the only way to make a custom merge tag like that would be to have the data your merge tag is pulling from in your list
Ariana: so if you add that data to your list, you could pull it
Ariana: but otherwise, I’m afraid not
Nate: hmm
Nate: not sure if that would work from what im trying …
Nate: can i run something past you real quick
Nate: ?
Nate: i have a plan but maybe you would have some insight into a better way of going about it with mailchimp
Nate: Im using the wordpress RSS feature
Ariana: ok
Nate: im sending my data over to the template, and the template catches the post ‘content’ thats all good
Nate: the issue im running into is the post also has meta data associated to it
Nate: for a table of values financial data…
Nate: anyway
Nate: im trying to send that on over as well into the news letter
Nate: my plan is to mash that all into the rss tag with a custom RSS
Nate: and mailchimp will get it and things will be all good
Nate: so i was asking before i write that
Nate: if i could just use some kind of tags to tap into other rss items
Nate: but the ones available to me are all listed in the cheat sheet yea?
Ariana: you can mash feeds together and you can pull specific elements of a feed using the different RSS feed merge tags found here: http://www.mailchimp.com/resources/merge/
Ariana: correct
Nate: ok got it
Nate: *Feature request, custom RSS merge tags :D
Nate: thanks for the help, Ariana.
Ariana: that would be a great addition to our withlist
Ariana: would you like to post it there?
Ariana: you’
Nate: sure what’s the link?
Ariana: you’re welcome! Here’s the wishlist URL: http://jungle.mailchimp.com/forum/topics/official-mailchimp-wishlist
Nate: ok i’ll do that
Nate: thanks have a good day!

——————
After a chat with mail chimp tech support, Im convinced there’s no way to make a custom RSS merge tag for what im trying to do at this time. That’s kinda sad, and I’ll go request it @ Mailchimp’s request forum. (a Ning account? fine.)

The plan now is to continue forth with mashing up the post content and post meta data into the content tag.

go here and request the feature, im currently waiting for approval: http://jungle.mailchimp.com/forum/topics/official-mailchimp-wishlist

Here’s my post to their request forum:
———-
Custom RSS merge tags.

So for example, lets say my RSS feed as a the fonz line… I’d like to be able to type into my MailChimp template:

The Cool guy on TV is still *|RSS:myCoolData|* .

Get the idea? That would be amazing.. I’m using this with WordPress and you see the issue im having is I’d love to send relevant meta data such as special tables that help support the post’s content. Right now im mashing up the post’s content and meta data into the and sending it to Mailchimp. It works but its not as clean as it could be.

There’s a banana in it for you…. get this feature to work and don’t look back. It will legen………..wait for it…….DARY.

Custom RSS merge tags… its so hot right now…. Custom RSS merge tags.
—————-

old parts-rss-skeleton.php (with wordpress php)
————–


			

*A good workflow for this is to have the MailChimp template preview open, and hit refresh while messing with the data. http://us1.admin.mailchimp.com/campaigns/preview-html?id=1091665

*I just tried to get nice, and use the *|RSSITEM:DESCRIPTION|* as an extra content field, but by default it will strip out any html.. no way to declare it as full content. HAha, figured as much but I had to try it. So the plan now is to use a full width template, and insert my own 2 column table layout, 1998 style.

So the work around is to combine all the HTML dependent elements into the content tag… so for small cap I need to have..
1) the most recent posts’s body copy in full
2) the 2 tables over on the small cap data sheet page, which gets updated from time to time.

The idea is to grab all 3 bits, and then string it together.

$recentPostQuery    = new WP_Query('category_name=smallcap&posts_per_page=1');
$smallCapTableQuery = new WP_Query('page_id=48');

$myContent = $recentPostQuery->post->post_content;

//all the content... needs to be seperated into 2 tables. smallCapTableTop10 and smallCapTablePortfolio
$smallCapTables = $smallCapTableQuery->post->post_content;

//extract the Top 10 table from small cap content
preg_match('|
(.*?)

|si', $smallCapTables, $smallCapTableTop10); //find the table based on ID
$smallCapTableTop10 = $smallCapTableTop10[0];

//extract the Portfolio table from small cap...
preg_match('|
(.*?)

|si', $smallCapTables, $smallCapPortfolio); //find the table based on ID
$smallCapPortfolio = $smallCapPortfolio[0];

$output    = array          (
'type'        => 'smallCap',
'content'     => $myContent.$smallCapTableTop10.$smallCapPortfolio,
'description' => ''
    	  	             );
?>

Those regex help to target the tables by ID.
*the regex says ‘match this literal string, plus whatever, up to the close bracket. Then grab everything int he middle, then stop at the close table tag. Also (si) treat that as one long line (s), and make the whole shabang case insensitive (i)

that content line in the array at the end, is the mashup, so when it hits the RSS stream it goes in one nice long line. Mailchimp will return that into a big blank template block. So once i get all the data there, i can style it.. I’ll have to rewrite those tables a bit since they were using divs and some CSS to display.

Now Im at the point where all the data makes it into the proper mailchimp template, and I need to construct some kind of mini template to insert into the mailchimp template. I’m using an approach of generating the skeleton table in photoshop with the slice tool, and dropping in the content. Formatting the text side of the data tables I think may require some regex to insert font tags in.. im not sure about the extent of inline css i can get away with when styling them. Trying to do a 2 column layout with this kind of data is a real pain in the ass, and Im not completely convinced its going to be usable when its done. Im going to see what’s possible, but I think the sheer amount of text in the portfolio table for small cap is going to kill it.

Home stretch now, just tweaking column width, and aesthetics.