• Resolved kimblebear

    (@kimblebear)


    Hi, I know this isn’t particularly a MailPoet problem – but I am completely stumped.

    How do I automatically display next month in a newsletter?

    I want to send out my april newsletter today – March 31st – but if I do, the shortcode text says March Edition.

    Without hard coding the word April into the newsletter, how can I do this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there @kimblebear,

    With the built-in shortcodes in MailPoet, it looks like there are only options for displaying the current month, date, day, year, etc.

    However, you can create custom shortcodes in MailPoet as well:
    https://kb.mailpoet.com/article/160-create-a-custom-shortcode

    I see in this thread here a clean option to always display the next month in PHP.

    So, you could use that to create a custom shortcode:

    add_filter('mailpoet_newsletter_shortcode', 'mailpoet_shortcode_for_next_month', 10, 6);
    function mailpoet_shortcode_for_next_month($shortcode, $newsletter, $subscriber, $queue, $newsletter_body, $arguments) {
      // always return the shortcode if it doesn't match your own!
      if ($shortcode !== '[custom:next_month]') return $shortcode; 
      
      return date('F',strtotime('first day of +1 month'));
    }

    Then use the shortcode [custom:next_month] to display the next month in your newsletter/Post Notification emails.

    I hope this helps! Please let me know if you have any questions.

    Thread Starter kimblebear

    (@kimblebear)

    Hi kellymetal a11n(@kellymetal)

    Thanks so much for your comprehensive post – really helpful and I’ll start work on it now

    Cheers

    Plugin Support Dani F. a11n

    (@danielinhou)

    Hi there!

    Hey, thanks for the update, I am glad to hear that we were able to put you in the right direction.

    Cheers

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Displaying next month’s date’ is closed to new replies.