Piotnet Forms Shortcode

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

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

Plugin Icon
Piotnet Forms

"Piotnet Forms is a powerful WordPress plugin that simplifies the process of creating, customizing, and managing forms. Ideal for beginners and advanced users, it's a must-have for interactive sites."

★★★★✩ (14) Active Installs: 4000+ Tested with: 6.0.6 PHP Version: 5.4
Included Shortcodes:
  • [piotnetforms]

Piotnet Forms [piotnetforms] Shortcode

The Piotnet Forms shortcode is a tool that dynamically generates form content. It retrieves form data from a specific post ID, decodes the JSON data, and renders the form content. It also manages the form’s styling by enqueuing the relevant CSS file. Additionally, it enqueues necessary scripts for functionality. The shortcode ends by returning the generated content.

Shortcode: [piotnetforms]


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

  • id – Unique identifier for specific contact form data

Examples and Usage

Basic example – The basic usage of the shortcode to display a form by referencing its unique ID.

[piotnetforms id=1 /]

Advanced examples

Displaying a form with a custom CSS file. The CSS file will be loaded from the piotnetforms/css/ directory in the WordPress uploads folder.

[piotnetforms id=1 css_file="custom.css" /]

Using the shortcode to display a form by referencing both ID and a custom CSS file. The form will first try to load by ID, and then apply the custom CSS file.

[piotnetforms id=1 css_file="custom.css" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'piotnetforms', 'piotnetforms_shortcode' );

Shortcode PHP function:

function piotnetforms_shortcode( $args, $content ) {
	if ( ! empty( $args['id'] ) ) {
		$post_id         = $args['id'];
		$raw_data = get_post_meta( $post_id, '_piotnetforms_data', true );
		if ( ! empty( $raw_data ) ) {
			echo '<div id="piotnetforms" class="piotnetforms" data-piotnetforms-shortcode-id="' . esc_attr( $post_id ) . '">';
			$data = json_decode( $raw_data, true );
			$widget_content = $data['content'];
			@piotnetforms_render_loop( $widget_content, $post_id );

			$upload = wp_upload_dir();
			$upload_dir = $upload['baseurl'];
			$upload_dir = $upload_dir . '/piotnetforms/css/';

			$css_file = $upload_dir . $post_id . ".css";
			wp_enqueue_style( 'piotnetforms-style-' . $post_id, $css_file, [], get_post_meta( $post_id, '_piotnet-revision-version', true ) );
			echo '</div>';
			wp_add_inline_script( 'main-asasasdasd', 'alert("hello world");' );
			wp_enqueue_script( 'main-asasasdasd' );
			wp_enqueue_script( 'piotnetforms-script' );
			wp_enqueue_style( 'piotnetforms-style' );
	return ob_get_clean();

Code file location:



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


Leave a Reply

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