Add post date to post notification newsletter
-
We’ve been using MailPoet2 for several years now and I would like to upgrade to MailPoet3.
But there’s one thing I can’t figure out.We need the post date in the newsletter that sends out post notifications.
We had built a workaround in MailPoet2 to replace the author with the post date (by replacing a line in the helpers/articles.php). It was a messy solution because it had to be changed manually everytime we updated the plugin, but it worked.
In MailPoet3 though, I don’t see any way to add the post date to the post notifications.
I tried building a custom shortcode, but it doesn’t work:
add_filter('mailpoet_newsletter_shortcode', 'mailpoet_add_date', 10, 5); function mailpoet_add_date($shortcode, $post) { // always return the shortcode if it doesn't match your own! if ($shortcode !== '[custom:eventdate]') return $shortcode; $eventdate .= "<b>".get_the_time('d.m.Y' , $post['ID'])."</b>"; return $eventdate; }
Adding “[custom:eventdate]” to the author or category line in display options does not work, though. I can think of a lot of reasons why it doesn’t :-). Maybe the variable $post is not available here? Or the input in the fields for display options cannot work with shortcodes?
Is there any way to have the post date appear in a post notifications newsletter?
Thanks a lot for your help!
Alicia
- The topic ‘Add post date to post notification newsletter’ is closed to new replies.