Jump to content

Jsharp85r

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Jsharp85r

  1. I've created a php code that automatically pulls post that are assigned to a category (dailydose) from my wordpress site and creates a daily mailchimp campaign using a email template. I now want to be able to pull ads that are assiocated with each post. So I'm stuck on how I can make that happen please help!! functions.php //wp_schedule_event( 1428610800, 'hourly', 'daily_dose_mailer' ); //wp_unschedule_event( time(), 'hourly', 'daily_dose_mailer' ); //wp_clear_scheduled_hook( 'daily_dose_mailer' ); add_action( 'daily_dose_mailer', 'daily_doser' ); function daily_doser(){ $cur_day = date( "w", time()); $standard_order = array("1","2","3","4","5"); if($cur_day >= 1 && $cur_day <= 5){ require_once 'includes/mailchimp-mailchimp-api-php-190cf58000ee/src/Mailchimp.php'; //Get content $custom_query = new WP_Query(array('post_type'=>'post','posts_per_page'=>5,'cat'=>1279)); $content = array(); $std_count = 0; while($custom_query->have_posts()) : $custom_query->the_post(); $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'single-post-thumbnail' ); if(get_post_meta(get_the_ID(),"dd_order",true) != "") $content[get_post_meta(get_the_ID(),"dd_order",true)] = array("title"=>get_the_title(),"summary"=>get_the_excerpt(),"link"=>get_permalink(),"image"=>$image[0]); else $content[$standard_order[$std_count]] = array("title"=>get_the_title(),"summary"=>get_the_excerpt(),"link"=>get_permalink(),"image"=>$image[0]); $std_count++; endwhile; $content_with_html = ''; $count = 1; $ad_count = 0; if($cur_day == 1) $ad_order = array("4","5","6","7","8"); if($cur_day == 2) $ad_order = array("8","4","5","6","7"); if($cur_day == 3) $ad_order = array("7","8","4","5","6"); if($cur_day == 4) $ad_order = array("6","7","8","4","5"); if($cur_day == 5) $ad_order = array("5","6","7","8","4"); foreach($content as $cont){ if(function_exists("wp_template_ad")) { $ad = wp_template_ad($ad_order[$ad_count]); } if($count == 1){ $content_with_html .= ' <tr> <td> <table style="width: 600px; margin: 10px 0;" width="600px"> <tbody> <tr> <td style="padding: 0px 0;"> <a href="'.$content[strval($count)]["link"].'" style="border-collapse: collapse; display: block; font-family: Arial Black, Gadget, sans-serif; font-weight: 900; font-size: 26px; line-height: 28px; color: #03030B; letter-spacing: -.03em; text-decoration: none;">'.$content[strval($count)]["title"].'</a> <a href="'.$content[strval($count)]["link"].'" style="text-decoration: none;float:right;" target="_blank"><img src="'.$content[strval($count)]["image"].'" style="width: 250px; min-height: 165px;" width="250" width="250" /></a> <p style="line-height: 18px; font-size: 12px; font-family: Georgia; margin: 0; padding: 0;"> <span style="font-size: 15px; line-height: 19px;">'.$content[strval($count)]["summary"].'</span><br><a href="'.$content[strval($count)]["link"].'" style="font-size: 14px; text-decoration: none; font-weight: bold; font-family: Arial Black, Gadget, sans-serif; color: #da1f3e;" target="_blank">READ MORE</a></p> </td> </tr> </tbody> </table> </td> </tr> <tr align="center"> <td bgcolor="#f3f3f3" style="background-color: #f3f3f3;"> '.$ad.'</td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /> <!--AD GOES HERE--> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '; }else{ $content_with_html .= ' <tr> <td style="padding: 13px 0;"> <a href="'.$content[strval($count)]["link"].'" style="border-collapse: collapse; display: block; font-family: Arial Black, Gadget, sans-serif; font-weight: 900; font-size: 20px; line-height: 24px; color: #03030B; letter-spacing: -.03em; text-decoration: inherit;">'.$content[strval($count)]["title"].'</a> <p style="line-height: 18px; font-size: 12px; font-family: Georgia; margin: 0; padding: 0;"> <span style="font-size: 12px; line-height: 18px;">'.$content[strval($count)]["summary"].'</span><br><a href="'.$content[strval($count)]["link"].'" style="font-size: 11px; text-decoration: none; font-weight: bold; font-family: Arial Black, Gadget, sans-serif; color: #da1f3e;" target="_blank">READ MORE</a></p> </td> </tr> <tr align="center"> <td bgcolor="#f3f3f3" style="background-color: #f3f3f3;"> '.$ad.'</td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /> <!--AD GOES HERE--> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '; } $count++; $ad_count++; } /*$content_with_html .= ' <tr align="center"> <td class="spacer"> '. wp_templol($ad_order[$ad_count]).'</td> </tr> ';*/ $MC = new Mailchimp('01a1ecf38bc12fdc975ff0c569945244-us1'); //Pseudo code //Grab the list that it will be sent to //lists/members (string apikey, string id, string status, struct opts) //Create markup of email - this also assigns the appropriate list //campaigns/create (string apikey, string type, struct options, struct content, struct segment_opts, struct type_opts) $retval = $MC->call('campaigns/create', array( "type"=>"regular", "options"=> array("list_id"=>"1924082bfe", "subject"=>"Your Daily Dose from DS News", "from_name"=>"DSNews", "from_email"=>"news@dsnews.com", "inline_css"=>true), "content"=> array("html"=>' <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Your Daily Dose of DS News</title> </head> <body> <div align="left" style="text-align: left; font-size: 12px; font-family: Century Gothic,Georgia,Verdana; padding-bottom: 50px !important;"> <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; margin: 0px;" width="728"> <tbody> <tr> <td align="center" bgcolor="#fff" colspan="2" style="padding: 5px; text-align: center;"> Email not displaying correctly? <a href="*|ARCHIVE|*">Display this email in your browser</a></td> </tr> <tr> <td align="center" bgcolor="#000" colspan="2" style="text-align: center; background-color: #000;"> <img alt="" height="30" src="http://admin.dsnews.com/editor_images/image_19b6f173/column.gif" style="width: 15px; min-height: 30px;" width="15" width="15" /> <table align="center" bgcolor="#000000" border="0" cellpadding="0" cellspacing="10px" width="600"> <tbody> <tr align="center" style="width: 600px;"> <td align="center" bgcolor="#FFF" style="padding: 0 0px; font-size: 12px; text-transform: uppercase; text-align: left; font-weight: bold; color: #fe0000; background-color: #000; font-family: Arial, Helvetica, sans-serif;"> *|DATE:l, M j, Y|*</td> <td align="right" bgcolor="#8a8b8a" style="font-size: 12px; text-transform: uppercase; padding: 0 0px; text-align: right; font-weight: bold; color: #fff; background-color: #000;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247987c4a6efb818978c" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000; letter-spacing: .003em;" target="_blank">HOME</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24791b911a59d15e5063" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">CONTACT US</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479f018cfa44911db10" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">MAGAZINE</a><a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479c6b1632e3f8df548" style="text-decoration: none; color: #000;" target="_blank"> </a>| <em><a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479ac6f4a1f6d5178c8" style="font-size: 12px; text-decoration: none; text-align: right; font-family: Arial Black, Gadget, sans-serif; color: #fff; background-color: #000;" target="_blank">SUBSCRIBE</a></em></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" style="width: 600px; margin: 0px auto;"> <tbody> <tr> <td width="600"> <div align="center" style="text-align: center;"> </div> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479b35fafb4d42723f5" style="text-decoration: none;" target="_blank"><img alt="DSNews.com | Daily Dose" height="109" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Daily-Dose.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 123px;" width="600" width="600" /></a></td> </tr> <tr> <td> <div align="center" style="text-align: center;"> </div> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> <tr> <td> <table style="width: 600px; margin: 0;"> <tbody> <tr> <td align="center" style="padding: 0px 0; text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24799b979aa344545f8a" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: none;"> DSNEWS.COM</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479db831868790c2639" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">REOREDBOOK</a>| <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479d269f0e3591d670f" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -0.03em; text-decoration: inherit;">BLACK BOOK</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247903105127fafb9dbc" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">FORCE</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247907d4c0d59b488676" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">GOVERNMENT FORUM</a> | <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247905ea889cdfee43cf" style="border-collapse: collapse; font-family: Arial Black, Gadget, sans-serif; font-size: 10px; color: #03030B; letter-spacing: -.003em; text-decoration: inherit;">FIVE STAR CONFERENCE</a></td> </tr> </tbody> </table> </td> </tr> <tr> <td> <img alt="" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/Solid-Line.jpg" style="display: block; border: 0px solid; text-align: center; width: 600px; min-height: 9px;" width="600" width="600" /></td> </tr> '.$content_with_html.' <tr> <td> </td> </tr> </tbody> </table> <table bgcolor="#f3f3f3" border="0" cellpadding="0" cellspacing="0" style="margin: 10px auto;" width="100%"> <tbody> <tr> <td> <table align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody> <tr> <td colspan="2"> <table style="width: 600px; margin: 10px auto;"> <tbody> <tr> <td align="center" style="width: 200px; text-align: center; padding-right: 5px;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24793af4e6a183b3ef6f" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank"><img alt="DSNews" height="50" src="http://dsnews.com/wp-content/uploads/sites/25/2014/01/ds.jpg" width="50" /></a></td> </tr> </tbody> </table> </td> </tr> <tr> <td align="center" style="font-size: 9px; text-align: left; color: #8a8b8a; border-top-color: #000; padding: 10px 0; border-top-style: groove; border-top-width: 2px;" width="280"> <strong style="color: #67c7d3; font-weight: normal;">Corporate Offices</strong> | Phone: 800.856.8060<br /> 1909 Woodall Rodgers, Suite 300 Dallas, Texas 75201</td> <td align="center" style="font-size: 9px; text-align: right; color: #8a8b8a; border-top-color: #000; padding: 10px 0; border-top-style: groove; border-top-width: 2px;" width="320"> <strong style="color: #67c7d3; font-weight: normal;">Washington Bureau</strong> | Phone: 202.393.5511<br /> 1101 Pennsylvania Ave. NW, Suite 600 | Washington, D.C. 20004</td> </tr> </tbody> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody> <tr> <td align="center" colspan="2" style="color: #8a8b8a; padding: 10px 0px; font-size: 7px; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: #252722; text-align: center;"> You are receiving this e-mail because you opted in at our Web site DSNews.com or attended a Five Star Conference. Copyright 2009 DS News. All rights reserved.<br /> <a href="*|UNSUB|*" style="text-decoration: none; color: #000000; " target="_blank">Unsubscribe.</a> <span style="line-height: 11.199999809265137px;">*|EMAIL|*<span style="font-size: 7px; line-height: 1.6em;"> from this list.</span></span></td> </tr> <tr> <td align="center" colspan="2"> <table style="width: 600px;"> <tbody> <tr> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e247963cf5f9844f5a817" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">DSNews.com</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479c36851c1fe0a7a08" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">REORedBook</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479f47338dd7e641363" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">BlackBook</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e2479b6f3467ce75a656b" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">TheFiveStar.com</a></td> <td align="center" style="text-align: center;"> <a href="http://link.dsnews.com/c/443/75a98e997857ea44b0bc30da975bb0f12b9e4c97445e24790cdf2f599aba04c2" style="font-size: 9px; text-decoration: none; color: #8a8b8a;" target="_blank">FORCE</a></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </td> </tr> </tbody> </table> </div> <br /> </body> </html> ') ) ); //Send it out //campaigns/send-test (string apikey, string cid, array test_emails, string send_type) - this will be replace by normal send // echo $retval; } }
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.