Newsletters: Dynamic Variables/Shortcodes

When added through the shortcode manager, the shortcodes are going to be wrapped in [raw] tags, this happens to prevent some themes from causing problems with the shortcode output.

All emails sent through the WordPress Newsletter plugin (not just newsletters, but expiration notifications, confirmation emails, etc…) are parsed through a method which checks for certain dynamic variable tags in the content and replaces these tags with values based on their purpose. Below is a list of all the available dynamic variables, together with a description for each.

Predefined Variables Shortcodes

  • [wpmlemail]
    Ouputs the email address of each individual subscriber.
  • [wpmlsubject]
    Display the title/subject of this newsletter in the content.
  • [wpmlhistoryid]
    Display the history ID of this newsletter in the content.
  • [wpmlunsubscribe]
    Generates an unsubscription link for each individual subscriber.
  • [wpmlblogname]
    Outputs the title of your WordPress blog.

    click to enlarge
  • [wpmlsiteurl]
    Outputs an absolute URL to your WordPress blog’s home page.
  • [wpmlmailinglist]
    Output the name of the mailing list being sent to.
  • [wpmlactivate]
    Generates an activation/confirmation link for each subscriber for the specific mailing list.
  • [wpmlmanage]
    Generates a link which will automatically validate a subscriber without requiring him to insert his email address, and takes him to a subscription management page.
  • [wpmlonline]
    Give your subscribers a link to view the newsletter online in their browser.
  • [wpmltrack]
    Inserts a tracking code into each individual email to track its read status. Ensure that you have tracking turned on in the Configuration in order for this to work. The way it work is it adds a 1 px by 1 px invisible image to each email. Each individual email sent through the plugin gets a unique tracking code. Ultimately, the tracking code alerts the plugin when a email is read by seeing if the invisible image is loaded.
  • [wpmldate {format}]
    By default, this shortcode is inserted into the newsletter content or template as [wpmldate]. Optionally, a ‘format’ parameter can be passed to it like this [wpmldate format="%d/%m/%Y"] to define the format of the date. By default, the format is ‘%d/%m/%Y’. You can also pass time format strings to the ‘format’ parameter. See the PHP strftime manual.
  • [wpmlbouncecount]
    Output the total email bounces for the subscriberOutput the total email bounces for the subscriber.
  • [wpmlcustomfields]
    Output all custom fields with values in a table for the subscriber
  • [wpmlsubscriberscount]
    Display the total number of subscribers in the database.
  • [wpmlpost_thumbnail]
    Display the featured image of the current post
  • [wpmlpost_permalink]
    Fetches the current post permalink

Custom Fields Variables Shortcodes

Apart from these predefined dynamic variables available, each of your custom fields in the mailing list will have their own dynamic variable so that you can personalize newsletters sent out to your subscribers. For example, if you create a custom field with the title “Birth Date“, you later on insert the dynamic variable “[wpmlfield name=”birth_date”]” into a newsletter to output the value of the custom field for each respectable subscriber.

WordPress Posts into Newsletters

There is a quick and easy way to insert an excerpt of your WordPress posts into your newsletters. It basically just adds a shortcode and defines all the parameters within the shortcode depending on your selection. To use this feature, simple click the white Envelope icon at the top of the TinyMCE editor, like this:

Once you’ve clicked on the envelope icon it will bring up a small popup block. From the popup window choose ‘WP Posts’ tab at the top. Now from here you can choose to insert a single post or multiple posts.

The other fields vary depending on this selection. The other fields define the parameters of the shortcode, such as how many posts to insert, which option to order the posts by, ascending or descending order, and the post categories. The image below shows everything said above:

Single Post

[wpmlpost post_id=15 showdate=Y language=en eftype=excerpt]
  • post_id: The ID of the post display.
  • showdate: Set this to “Y” to show the date of the post and “N” to not show it.
  • language: language code for the language of the post when qtranslate is installed.
  • eftype: Set this to “full” to show the complete post or “excerpt” to show only a resume

Multiple Posts

[wpmlposts numberposts=10 orderby=post_date showdate=Y order=DESC category=0 language=en post_type=movies,products eftype=excerpt]
  • language: This is only when qTranslate is installed and active and contains the language code.
  • numberposts: The number of posts that should be displayed,  you can limit the number of posts to display within a category.
  • showdate: This can be “Y” to show the date or “N” to show no post date.
  • orderby:: You can order post by the way you would like it to show like by date, Author, Category, Post_ID etc.
  • order: The other fields define the parameters of the shortcode, such as how many posts to insert, which option to order the posts by, ascending or descending order, and the post categories.
  • category: is determined by the number of the category you choose, ranging between one and however many categories you have
  • post_type: Choose the custom post types to make posts from.
  • eftype: Set this to “full” to show the complete post or “excerpt” to show only a resume

So now you know how to insert an excerpt or the full text of your WordPress Posts into your newsletters, simply just choose the variables from the dropdowns according to your needs for the parameters.

Table of Contents