Quick Contact Form Shortcode

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

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

Plugin Icon
Quick Contact Form

"Quick Contact Form is a WordPress plugin that allows you to easily create and embed contact forms. With its intuitive interface, you can customize forms to suit your needs."

★★★★☆ (20) Active Installs: 2000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [qcf]

Quick Contact Form [qcf] Shortcode

The Quick Contact Form shortcode is a function that enables a specific form to be displayed. This shortcode uses the ‘qcf_start’ function, which accepts attributes for ‘id’ and ‘form’. If an ‘id’ is specified, it’s used; otherwise, the ‘form’ attribute is used. The ‘id’ is then sanitized to remove any non-alphabetic characters. Lastly, the function ‘qcf_loop’ is called with the ‘id’ as an argument, generating the desired form.

Shortcode: [qcf]

Parameters

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

  • id – Specifies the unique identifier of the contact form.
  • form – Provides an alternative identifier if ‘id’ is not set.

Examples and Usage

Basic example – Displays a contact form by referencing the ID.

[qcf id='contact_form_1' /]

Advanced examples

Displays a contact form by referencing the form title. If the form with the given ID is not found, it will try to load the form by the title.

[qcf form='Contact Form 1' /]

Displays a contact form by referencing both ID and form title. The form will first try to load by ID, but if not found, it will try to load by the title.

[qcf id='contact_form_1' form='Contact Form 1' /]

Note: In the above examples, ‘contact_form_1’ and ‘Contact Form 1’ are just placeholders. Replace them with your actual form ID or title.

PHP Function Code

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

Shortcode line:

add_shortcode( 'qcf', 'qcf_start' );

Shortcode PHP function:

function qcf_start( $atts )
{
    $atts = shortcode_atts( array(
        'id'   => '',
        'form' => '',
    ), $atts );
    
    if ( !empty($atts['id']) ) {
        $id = $atts['id'];
    } else {
        $id = $atts['form'];
    }
    
    $id = preg_replace( "/[^A-Za-z]/", '', $id );
    return qcf_loop( $id );
}

Code file location:

quick-contact-form/quick-contact-form/legacy/quick-contact-form.php

Conclusion

Now that you’ve learned how to embed the Quick Contact Form 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 *