A shortcode is a short code in square brackets that WordPress replaces with content. The [mailerpress_optin] shortcode displays a MailerPress sign-up form anywhere on your site: in a page builder module or widget (Elementor, Bricks, Divi and others), in the classic editor, or in your theme’s PHP templates. It is included in MailerPress (free).
Using the block editor? The Subscription Form block is easier to set up. With MailerPress Pro, Elementor, Bricks Builder and Divi also have dedicated integrations: Elementor, Bricks Builder and Divi Builder.
Quick setup
Add this shortcode where the form should appear:
[mailerpress_optin list="1"]Replace 1 with your list ID. On the MailerPress lists page, the Shortcode column shows a ready-to-copy shortcode for each list. The tags page does the same for tags. Without list, new contacts go to your default list (see Manage Your Contact List).
By default, the form shows only the email field and a Subscribe button. Add attributes (options written inside the brackets, like list="1") to change it.
Shortcode attributes
| Attribute | Description | Default |
|---|---|---|
list | List IDs, separated by commas, for example list="1,2". | Default list |
tags | Tag IDs, separated by commas, for example tags="5,10". | None |
show_first_name | Show the first name field. | false |
show_last_name | Show the last name field. | false |
email_required | Make the email field required. | true |
first_name_required | Make the first name field required. | false |
last_name_required | Make the last name field required. | false |
email_label | Label of the email field. | |
first_name_label | Label of the first name field. | First Name |
last_name_label | Label of the last name field. | Last Name |
email_placeholder | Placeholder of the email field. | Enter your email |
first_name_placeholder | Placeholder of the first name field. | Enter your first name |
last_name_placeholder | Placeholder of the last name field. | Enter your last name |
button_text | Text of the button. | Subscribe |
button_color | Button background color (hex code, for example #0073aa). | #000 |
text_color | Button text color (hex code). | #fff |
border_radius | Button border radius, for example 8px. | 0px |
success_message | Message shown after a successful sign-up. | Thank you for your registration. |
error_message | Message shown when the sign-up fails. | Oops! Something went wrong. Please try again. |
redirect | Page to open after a successful sign-up: the ID of a post, page or other post type, or a full URL. | None |
The default labels and messages appear in your site’s language.
Examples
Simple form with a custom button:
[mailerpress_optin list="1" button_text="Register"]Form with tags:
[mailerpress_optin list="1" tags="5,10" button_text="Join us"]Styled button:
[mailerpress_optin list="1" button_color="#e74c3c" text_color="#fff" border_radius="8px"]Redirect to a thank-you page (ID 123) after sign-up:
[mailerpress_optin list="1" redirect="123"]Complete form with a required first name:
[mailerpress_optin list="1" tags="5" show_first_name="true" first_name_required="true" show_last_name="true" first_name_label="First Name" last_name_label="Last Name" email_label="Email" email_placeholder="[email protected]" button_text="Subscribe" button_color="#2c3e50" success_message="Thank you for subscribing!"]Use the shortcode in a PHP template
To display the form from your theme or child theme, add this line to a template file:
<?php echo do_shortcode( '[mailerpress_optin list="1"]' ); ?>Good to know
- Double opt-in (the new contact confirms by clicking a link in an email) follows MailerPress > Settings > Sign-up Confirmation, enabled by default and recommended. No shortcode attribute changes it. See Enable sign-up confirmation (double opt-in).
- Colors must be hex codes (for example
#000,#fffor#0073aa). An invalid color falls back to the default. - For true/false attributes, use
"true"or"false". The values1,yesandonalso mean true. - Your theme styles apply to the form. To target it in custom CSS, use the
mailerpress_shortcode-optin-formclass. The button also has the standardbuttonclass. - Rate limiting (a cap on sign-ups in a short time), set in MailerPress > Settings > Spam Protection, applies to shortcode forms. See Security & Spam Protection.