Constant Contact Forms Shortcode

Below, you’ll find a detailed guide on how to add the Constant Contact Forms 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 Constant Contact Forms Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Constant Contact Forms Plugin and the shortcodes it provides:

Plugin Icon
Constant Contact Forms

"Constant Contact Forms is a beneficial WordPress plugin that simplifies the process of creating and embedding custom forms on your website, making it easier to engage and connect with your visitors."

★★☆✩✩ (82) Active Installs: 30000+ Tested with: 6.3.0 PHP Version: 7.4
Included Shortcodes:
  • [ctct]

Constant Contact Forms [ctct] Shortcode

The Constant Contact Forms shortcode is a tool that enables the display of a specific form on your WordPress site. It uses the render_shortcode function to process attributes, verify the form’s existence, and handle title visibility.

Shortcode: [ctct]

Parameters

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

  • form – The ID of the contact form to be displayed.
  • show_title – If set to ‘true’, the title of the form is displayed.

Examples and Usage

Basic example – A simple way to use the shortcode to display a contact form by referencing its ID.

[ctct form=1 /]

Advanced examples

Displaying a contact form by referencing its ID and deciding whether to show the title or not. If ‘show_title’ is set to ‘true’, the title of the form will be displayed, otherwise, it will be hidden.

[ctct form=1 show_title=true /]

Using the shortcode to display a contact form by referencing both ID and title. The form will first try to load by ID, but if not found, it will try to load by title. If ‘show_title’ is set to ‘true’, the title of the form will be displayed.

[ctct form=1 show_title=true /]

Please note that in the above examples, replace ‘1’ with the actual ID of your contact form. Also, set ‘show_title’ to either ‘true’ or ‘false’ based on your requirements.

PHP Function Code

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

Shortcode line:

add_shortcode( $this->tag, [ $this->plugin->display_shortcode, 'render_shortcode' ] );

Shortcode PHP function:

function render_shortcode( $atts ) {

		$atts = shortcode_atts(
			$this->plugin->shortcode->get_atts(),
			$atts,
			$this->plugin->shortcode->tag
		);

		if ( ! isset( $atts['form'] ) ) {
			return '';
		}

		$show_title = ( isset( $atts['show_title'] ) && 'true' === $atts['show_title'] ) ? true : false;

		return $this->get_form( $atts['form'], $show_title );
	}

Code file location:

constant-contact-forms/constant-contact-forms/includes/class-shortcode.php

Conclusion

Now that you’ve learned how to embed the Constant Contact Forms 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.

Comments

Leave a Reply

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