Campaign Monitor for WordPress Shortcode

Below, you’ll find a detailed guide on how to add the Campaign Monitor for WordPress Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Campaign Monitor for WordPress Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Campaign Monitor for WordPress Plugin and the shortcodes it provides:

Plugin Icon
Campaign Monitor for WordPress

"Campaign Monitor for WordPress is a powerful plugin that integrates your website with the Campaign Monitor email marketing service. It simplifies form creation and data collection."

★☆✩✩✩ (37) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: 5.3
Included Shortcodes:
  • [cm_form]

Campaign Monitor for WordPress [cm_form] Shortcode

The Forms-for-Campaign-Monitor plugin shortcode, ‘cm_form’, is used to generate an embedded form within a WordPress page or post. The ‘cm_form’ shortcode calls the ‘generateShortcode’ function. This function extracts attributes like ‘type’ and ‘form_id’. If ‘form_id’ is not empty, it appends HTML divs for form and button containers to the content.

Shortcode: [cm_form]


Here is a list of all possible cm_form shortcode parameters and attributes:

  • type – Determines the form’s display style, default is embedded
  • form_id – Unique identifier of the contact form

Examples and Usage

Basic example – A simple usage of the shortcode to generate a form with a specific ID.

[cm_form form_id=1 /]

Advanced examples

Generating an embedded form with a specific ID. The form will be hidden initially and will only be displayed when needed. This is useful for forms that are loaded conditionally, for example, based on user interaction.

[cm_form type='EMBEDDED' form_id=2 /]

Generating a form without specifying the form ID. In this case, the form ID will be determined by the Application::$shortCodeId variable. This is useful when the form ID is dynamic and not known at the time of writing the shortcode.

[cm_form /]

Generating a form with a specific ID and appending custom HTML content to it. The additional content will be appended to the form container and can be used to provide additional information or instructions to the user.

[cm_form form_id=3]Additional content goes here...[/cm_form]

Please note that these examples assume that the form with the specified ID exists and is properly configured in the Campaign Monitor.

PHP Function Code

In case you have difficulties debugging what causing issues with [cm_form] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'cm_form', array(__CLASS__, 'generateShortcode') );

Shortcode PHP function:

function generateShortcode($attributes, $content = "" ){
            'type' => FormType::EMBEDDED,
            'form_id' => '',
        ), $attributes));

        if (!empty($form_id)){
            Application::$shortCodeId = $form_id;
            $content .= '<div class="cmApp_embedFormContainer" style="display:none;"></div><div class="cmApp_FormButtonContainer" style="display:none;"></div>';


        return $content;

Code file location:



Now that you’ve learned how to embed the Campaign Monitor for WordPress Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.


Leave a Reply

Your email address will not be published. Required fields are marked *