You can use the [[posts]] merge tag to display posts, pages, products, or any other custom post types in any email campaigns that you send via Noptin.

What’s the difference between the [[posts]] merge tag and the [[post_digest]] merge tag?

The two merge tags are identical. The main difference is that the [[post_digest]] merge tag can only be used inside a post-digest campaign whereas a [[posts]] merge tag can be used anywhere.

Another difference is that the [[post_digest]] merge tag only displays posts that were published since the last time the campaign was sent.

Pre-requisites

To follow along with this tutorial, you’ll need to:-

  1. Install the latest version of Noptin.
  2. Install the latest version of the Ultimate Add-ons Pack.

The [[posts]] merge tag is only available if you’re using the Ultimate Add-ons Pack. The following sections contain some examples that you can use.

Filter posts by the post type

By default, Noptin will only display blog posts. You can use the post_type parameter to display pages, products, or any other custom post type.

For example,

The example below will display pages…

[[posts post_type="page"]]

… while this example displays WooCommerce products.

[[posts post_type="product"]]

Filter posts by the author

You can use the following parameters to filter posts by the author.

  • author – displays posts whose author has the specified ID, for example, author=1.
  • author_name – filters posts by the author’s ‘user_nicename‘ – NOT the display name, for example, author_name=admin.
  • author__in – filters posts by several author IDs, for example, author_in=1,3,4.
  • author__not_in – excludes several authors by their IDs, for example, author_not_in=1,3,4

Example,

This merge tag displays posts by the author with user ID 6:-

[[posts author=6]]

The merge tag below is similar to the above but uses the user_nicename instead of the user ID.

[[posts author_name="admin"]]

You can also display posts from several authors as shown in the example below. Note that the author IDs are separated using a comma.

[[posts author__in="1,3,5"]]

You can exclude posts from specific authors as shown below:-

[[posts author__not_in="1,3,5"]]

Filter posts by categories

Important

Only blog posts have categories. All other custom post types use custom taxonomies.

For example,

Product categories in WooCommerce are actually a custom taxonomy known as product_cat.

This means that this section is irrelevant if you’re using your merge tag to display custom post types.

You can display blog posts that have a given category (and any children of that category) by providing the category ID as shown in the example below:

[[posts cat=8]]

This is the same as above except that it ignores child categories:

[[posts category__in=8]]

You can also use the category slug:

[[post_digest category="tutorials"]]

To display blog posts that have several categories, use a comma to separate the category ids as shown below:-

[[posts cat="5,7"]]

This is the same as above except that it does not show posts from any children of these categories:-

[[posts category__in="5,7"]]

You can also use category slugs. The example below will only display blog posts that are EITHER categorized as tutorials OR news.

[[post_digest category="tutorials,news"]]

To display blog posts that have ALL of these categories, use a plus (+) instead of a comma (,). The example below will only display blog posts that are categorized as BOTH tutorials and news.

[[post_digest category="tutorials+news"]]

You can also use the category ID instead of the slug as shown below:

[[post_digest category__and="5,7"]]

To display all blog posts except those from a given category, prefix its id with a minus sign (-). The example below will only display posts from the category with ID 14 and skip those that have either category ID 10 or 29.

[[post_digest cat="-10,14,-29"]]

You can also exclude multiple categories this way:

[[post_digest category__not_in="5,7"]]

Filter posts by tags

Important

Only blog posts have tags. All other custom post types use custom taxonomies.

For example,

Product tags in WooCommerce are actually a custom taxonomy known as product_tag.

This means that this section is irrelevant if you’re using your merge tag to display custom post types.

You can display blog posts that have a given tag as shown in the example below (note that we’re using the tag’s slug):

[[post_digest tag="video"]]

This is the same as above but we’re using the tag’s ID instead of the tag’s slug:

[[post_digest tag_id=5]]

The example below will display blog posts that have EITHER the tags tutorials OR news.

[[post_digest tag="tutorials,news"]]

This is the same as above except that it uses the tags’ IDs instead of slugs.

[[post_digest tag__in="5,7,13"]]

Use a plus (+) instead if you want to display blog posts that have BOTH tags.

[[post_digest tag="tutorials+news"]]

This is the same as above except that it uses the tags’ IDs instead of slugs.

[[post_digest tag__and="5,7,13"]]

You can also display blog posts that do not have any of the two tag ids 3 and 4:

[[post_digest tag__not_in="3,4"]]

Filter posts by custom taxonomies

Noptin allows you to filter posts by custom taxonomies. All you have to do is pass the custom taxonomy name as a parameter key and then pass the term as the parameter value.

For example,

The following merge tag will display products that have the product_cat taxonomy set to hoodies. WooCommerce registers the product category taxonomy as product_cat.

[[post_digest post_type="product" product_cat="hoodies"]]

This is the same as above but we’re using the term’s ID instead by adding ‘_ids‘ to the taxonomy:

[[post_digest post_type="product" product_cat_ids="5"]]

The example below will display products that have EITHER been categorized as hoodies OR tshirts.

[[post_digest post_type="product" product_cat="hoodies,tshirts"]]

This is the same as above except that it uses the terms’ IDs instead of slugs.

[[post_digest post_type="product" product_cat_ids="5,7,13"]]

Append ‘_and' to a taxonomy to display posts that have ALL the terms.

[[post_digest post_type="product" product_cat_and="hoodies,tshirts"]]

This is the same as above except that it uses the terms’ IDs instead of slugs.

[[post_digest post_type="product" product_cat_ids_and="5,7,13"]]

You can exclude multiple terms by appending ‘_not_in‘ to the taxonomy as shown:

[[post_digest post_type="product" product_cat_not_in="hoodies,tshirts"]]

This works the same as the above example except it uses the term IDs instead of slugs:

[[post_digest post_type="product" product_cat_ids_not_in="3,4"]]

Not sure how to find the taxonomy name?

Open the taxonomy’s management page. You’ll see the correct taxonomy name in the URL.

Checking the correct taxonomy name

Filter posts by custom fields

Noptin allows you to filter posts by custom fields as shown in the examples below:-

This example will display posts that have the custom field key ‘color’, regardless of the custom field value:

[[posts meta_key="color"]]

The reverse is also true as shown in the example below which displays posts where the custom field value is red, regardless of the custom field key.

[[posts meta_value="red"]]

Combining the two allows you to check for both the custom field key and value as shown in the below example which only displays posts where the custom field key is color and the custom field value is red.

[[posts meta_key="color" meta_value="red"]]

Use meta_value_num instead of meta_value in cases where the meta value is a number as shown in the example below:-

[[posts meta_key="_price" meta_value_num=20]]

The meta_compare parameter allows you to specify the comparison to use when comparing the meta value as shown in the example below:-

[[posts meta_key="_price" meta_value_num=20 meta_compare="<="]]

Possible values for meta_compare are:-

ComparisonDescription
=(Default) Is equal to
!=Is not equal to
>Is greater than
>=Is greater than or equal to
<Is less than
<=Is less than or equal to
LIKEIs like
NOT LIKEIs not like
INIs in
NOT INIs not in
BETWEENIs between
NOT BETWEENIs not between
EXISTSExists
NOT EXISTSDoes not exist
REGEXPMatches a regular expression
NOT REGEXPDoes not match the regular expression
Possible comparisons you can use with custom fields

The meta_query parameter allows you to filter by multiple custom fields and specify advanced field types such as dates and times.

Important Note:

The meta_query parameter takes an array of meta query arguments arrays (it takes an array of arrays) – you can see this in the examples below.

Each array can contain any (or all) of the following keys.

KeyDescription
keyRequired. The custom field key
valueThe custom field value.
Can be a comma-separated array if compare is 'IN''NOT IN''BETWEEN', or 'NOT BETWEEN'.
You don’t have to specify a value when using the 'EXISTS' or 'NOT EXISTS'
compareOperator to test.
Possible values are ‘=’, ‘!=’, ‘>’, ‘>=’, ‘<‘, ‘<=’, ‘LIKE’, ‘NOT LIKE’, ‘IN’, ‘NOT IN’, ‘BETWEEN’, ‘NOT BETWEEN’, ‘EXISTS’ and ‘NOT EXISTS’.
The default value is ‘=’.
typeCustom field type.
Possible values are ‘NUMERIC’, ‘BINARY’, ‘CHAR’, ‘DATE’, ‘DATETIME’, ‘DECIMAL’, ‘SIGNED’, ‘TIME’, ‘UNSIGNED’.
The default value is ‘CHAR’.
formatYou can provide a format if type is set to either ‘DATE’, ‘DATETIME’, or ‘TIME’.
Allowed meta query keys

Meta query examples:-

Display upcoming events

[[posts post_type="event" meta_query="0[key]=event_date&0[compare]=>=&0[type]=DATE&0[value]=today&0[format]=Ymd"]]

Things to note:-

1. Meta query accepts an array of arrays. 0[key]=event_date is the first array whereas 1[key]=event_town is the second array.

2. You can provide any strtotime readable dates if the field type is either ‘DATE’, ‘DATETIME’, or ‘TIME’.

3. You can pass a date or time format in a format key. You can check the allowed characters here.

Combine multiple custom fields.

[[posts post_type="product" meta_query="0[key]=color&0[value]=blue&0[compare]=NOT LIKE&1[key]=price&1[value]=20, 100&1[compare]=BETWEEN&1[type]=NUMERIC"]]

The above example displays posts that match both custom fields. You can set the relation parameter to “OR” if you only want to match a single parameter from the list.

[[posts post_type="product" meta_query="relation=OR&0[key]=color&0[value]=blue&0[compare]=NOT LIKE&1[key]=price&1[value]=20, 100&1[compare]=BETWEEN&1[type]=NUMERIC"]]

Limit the number of posts to display

By default, Noptin will display a maximum of 10 posts. You can change this as shown below:-

[[posts limit=20]]

The above example displays a maximum of 20 posts whereas the below example displays all posts.

[[posts limit=-1]]

You can also display all posts by disabling pagination as shown below:-

[[posts nopaging=1]]

The limit parameter allows you to skip the first X posts.

For example,

You can skip the first 5 posts as shown below:-

[[posts limit=5 offset=5]]

NOTE:

The limit parameter is ignored when displaying all posts.

Noptin ignores sticky posts by default. You can change this as shown below:-

[[posts ignore_sticky_posts=0]]

Change the order of posts

By default, Noptin will order your posts by the date they were published in descending order. You can change this as shown below:-

[[posts order="ASC"]]

The orderby attribute allows you to order your posts by another field other than the date it was published.

This example shows how to order the posts in your digest email by their title in ascending order.

[[post_digest orderby="title" order="ASC"]]

The orderby attribute accepts one of:-

ValueDescription
IDOrders posts by their ID.
authorOrders posts by their author.
titleOrders posts by their title.
typeOrders posts by their post type.
dateOrders the posts by their creation date.
modifiedOrders the posts by their last modification date.
parentOrders the posts by their parent ID. This is useful if you need to group posts by their parents.
randOrders the posts randomly.
menu_orderOrders pages or custom post types by their page order.
comment_countOrders the posts by the number of comments/popularity.
meta_valueOrders the posts by their meta values. Only use this if you’ve set the meta key attribute.
meta_value_numSimilar to above, but in cases where the meta_value expects a numeric value.
Accepted order by parameters

You can specify several values for the orderby attribute as shown in the next example which orders products by their prices and falls back to their titles in cases where two or more products have the same prices.

[[post_digest post_type="product" meta_key="_price" orderby="meta_value_num title" order="DESC"]]

Related Guides

  • Visual Email Editor

    The visual email editor is a simple to use and a responsive editor for crafting and sending emails to your customers. The editor is user-friendly as it has inbuilt elements that allow you to drag and drop across your email fields for easier design. Therefore, you do not have to be a programmer to use…

    Read More

  • How to auto log-in users that click on links in your email campaigns

    Use the PHP code snippet below to auto-login users who click on links in your email campaigns. This is useful, for example, when sending an abandoned cart email series or custom magic login links. Code Explanation

    Read More

  • Tracking revenue generated per email

    Noptin allows you to track revenue generated per email. How to enable Open the Noptin settings page and mark both “Show campaign stats” and “Enable e-Commerce tracking” as shown below. How it works Supported Plugins Revenue is currently tracked for the following plugins:-

    Read More

  • How to fix emails not sending

    This tutorial will show you how to fix emails not sending or only sending to a portion of your subscribers. Fix emails only sending to a few subscribers Check sending limits First, check if your host (or email sender) has email-sending limits. If they do, inquire about their hourly limits then set it via Noptin…

    Read More

  • How to send a welcome email to imported subscribers

    Noptin allows you to send a welcome email to imported subscribers. To do this:- First, click on Noptin > Email Campaigns > Automated Emails to open the automated emails overview page. Next, click on the New Automated Email button and then select “Subscriber > Imported” under the Subscribers tab. Finally, select “Manual Recipients” as the…

    Read More

  • [Paid Memberships Pro] How to filter email recipients by their membership level

    Learn how to attach lead magnets and other attachments to your email newsletters and automated email campaigns.

    Read More

  • How to attach files to your email campaigns

    Learn how to attach lead magnets and other attachments to your email newsletters and automated email campaigns.

    Read More

  • How to send an email to all your newsletter subscribers

    Noptin allows you to send an email to all your newsletter subscribers. To do this:- First, click on Noptin > Email Campaigns to open the email campaigns management page. Next, click on the “New Campaign” button to open the email campaign creation page. Finally, click on the “Noptin Subscribers” button to create a new campaign.…

    Read More

  • How to Send an Email to All your WordPress Users

    This guide shows you how to send an email to all your WordPress users, or only those who have a certain user role.

    Read More

  • How to set up Automated Emails

    What are automated emails and how do you set them up?

    Read More

  • How to send an email to your WooCommerce Customers

    Learn how to send a mass email to all your WooCommerce customers, or only customers who bought specific products.

    Read More

  • New Post Notifications

    Learn how to automatically notify users whenever you publish new content, or set-up a daily, weekly, or monthly digest of your latest content.

    Read More

  • Automatically Send an Email to New Subscribers

    This guide shows you how to automatically send a welcome email to new email subscribers or set up a series of welcome emails to act as an email course.

    Read More

  • Automatically email your subscribers when the join or leave a list

    This guide shows you how to automatically send an email to your WordPress subscribers whenever they are added or removed from a list

    Read More

  • Automatically Send an Email to Email Subscribers Whenever they are Tagged or Untagged

    This guide shows you how to send a welcome email to your WordPress subscribers whenever you tag or untag them

    Read More

  • Automatically Send an Email to New WordPress Users

    This guide shows you how to send a welcome email to new WordPress users or set up a series of welcome emails to act as an email course.

    Read More

  • How to Automatically Send a Welcome Email to New WooCommerce Customers

    This guide shows you how to send a welcome email to new WordPress users or set up a series of welcome emails to act as an email course.

    Read More

  • Sending Expired Card Notification Emails

    This guide shows you how to send a welcome email to new WordPress users or set up a series of welcome emails to act as an email course.

    Read More

  • Email Sending Limits

    By default, when you send a newsletter campaign, Noptin will send out the email to as many subscribers as it can. This can cause a problem for those of us who use a shared hosting provider, since most of them have a limit on how many emails you can send per hour. Since Noptin version…

    Read More

  • Using a WordPress SMTP Plugin to Send your Newsletter Emails

    Noptin uses the same method that WordPress uses to deliver its emails. The default email delivery method is to send the email directly via your web server or hosting provider. The main problem with sending emails via your web server is that most of the emails will be marked as SPAM. In addition, most web…

    Read More

  • Email Templates

    Noptin does not come with a drag-and-drop email builder. Instead, it uses email templates to customize the look of your emails. You can think of an email template as a WordPress theme. It is given the email heading, content, and footer text and then produces the final HTML email. This allows you to do awesome…

    Read More

  • Merge Tags

    You can use email tags (also known as merge tags) to display dynamic and personalized content in your emails and success messages. This guide shows you how to personalize your emails and success messages using merge tags. What is a Merge Tag? A merge tag is a placeholder that allows you to personalize email campaigns…

    Read More

  • Troubleshooting

    Sometimes Noptin won’t be able to send emails to your subscribers. Whenever this happens, the problem will probably be with WordPress (or your SMTP plugin) and not Noptin. This is because Noptin uses WordPress to send its emails instead of sending them manually. This guide shows you how to troubleshoot most of the issues which…

    Read More

  • Troubleshooting Logos Not Showing in Noptin Emails

    If your logos are not displaying in your Noptin emails, it can be frustrating, but there are a few common issues you can check to resolve this problem. This guide will walk you through troubleshooting steps to ensure your logo appears correctly in your emails. 1. Verify the Logo URL The most common reason for…

    Read More

  • How to display past newsletter issues on your site

    Learn how to display past newsletter issues on your website using the [past_noptin_newsletters] shortcode

    Read More

  • How to Set Up an External CRON Job in WordPress and speed up email sending

    WordPress has a built-in scheduling system called WP-Cron, designed to handle time-based tasks. This is what Noptin uses when sending emails in the background. However, it is not often reliable as it is tied to your website traffic. This guide will walk you through the process of setting up an external CRON job for WordPress,…

    Read More

  • How to Bulk Edit Subscribers

    Sometimes, you might want to filter your email subscribers based on similar characteristics such as subscriber status, source or using given tags. This guide will show you how to edit your subscribers in bulk, saving you a lot of time. Login in to your WordPress Admin Panel, then on the right menu select Noptin >…

    Read More

  • How to Include a ‘View in Browser’ Link in Your Noptin Email Campaigns

    Adding a “View in Browser” link to your email campaigns allows recipients to open and view your email in their web browser. This can be especially useful for users who may have difficulty viewing the email in their email client or prefer to see it in a web format. With Noptin, you can easily include…

    Read More