Weforms Shortcode

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

Before starting, here is an overview of the Weforms Plugin and the shortcodes it provides:

Plugin Icon
weForms – Easy Drag & Drop Contact Form Builder For WordPress

"weForms is an intuitive drag & drop contact form builder for WordPress. It simplifies form creation with user-friendly features, making it ideal for both beginners and professionals."

★★★★☆ (107) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 7.2
Included Shortcodes:
  • [weforms]

Weforms [weforms] Shortcode

The ‘weforms’ shortcode is used to render a specific form on a webpage. It uses the form ID, specified in the ‘id’ attribute, to fetch and display the form. If the form is not found or submission is closed, it displays an error message. The shortcode ensures all necessary scripts are loaded before rendering the form.

Shortcode: [weforms]


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

  • id – Unique identifier of the form to be displayed

Examples and Usage

Basic example – The following shortcode displays a form by referencing the form’s ID. This is the most common way to use the weforms shortcode.

[weforms id=1 /]

Advanced examples

Using the shortcode to display a form by referencing both ID and a custom attribute. This example assumes you’ve added a custom attribute to your form. It first tries to load the form by ID, but if not found, it will try to load by the custom attribute.

[weforms id=1 custom_attr='value' /]

Using the shortcode to display a form by referencing the form’s ID and setting a custom class. This allows you to style the form differently from other forms on your site.

[weforms id=1 class='custom-class' /]

Using the shortcode to display a form by referencing the form’s ID and setting a custom style. This allows you to apply inline CSS to your form.

[weforms id=1 style='color:red;' /]

Please note that these examples assume that you have the necessary custom attributes, classes, or styles added to your forms. If not, you may need to modify your forms or your theme’s CSS to use these advanced examples.

PHP Function Code

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

Shortcode line:

add_shortcode( 'weforms', [ $this, 'render_shortcode' ] );

Shortcode PHP function:

function render_shortcode( $atts, $contents = '' ) {
        extract( shortcode_atts( [ 'id' => 0 ], $atts ) );



        $form = weforms()->form->get( $id );

        if ( !$form->id ) {
            return $this->show_error( __( 'The form couldn\'t be found.', 'weforms' ) );

        $is_open = $form->is_submission_open();

        if ( is_wp_error( $is_open ) ) {
            return $this->show_error( $is_open->get_error_message() );

        $this->render_form( $form, $atts );

        return ob_get_clean();

Code file location:



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