Loading scripts on specific pages only

In a future version of the plugin you will be able to limit the pages that the JavaScript and CSS appears on from inside the plugin settings. But for now you will need to edit one of the plugin files manually. Please follow the steps below.

Only enqueue scripts on a single page/post

Step 1

Get the ID of the post or page that you want to display the Quform JavaScript/CSS on. You can find this number in the address bar when editing the post/page.

Step 2

Open the file iphorm-form-builder/includes/common.php and search for function iphorm_enqueue_styles(). This is the function that enqueues the CSS for the plugin. Inside this function, on the line below the opening curly bracket, add the code below. Note: replace 123 with your post ID from Step 1. What this code does is prevent the plugin enqueuing the plugin CSS if we are not on the specified post/page.

1
2
global $post;
if (!isset($post->ID) || $post->ID != 123) return;
global $post;
if (!isset($post->ID) || $post->ID != 123) return;

Step 3

In the same file, search for function iphorm_enqueue_scripts(). This is the function that enqueues the JavaScript for the plugin. Inside this function, on the line below the opening curly bracket, add the code below. Note: replace 123 with your post ID from Step 1. What this code does is prevents the plugin enqueuing the plugin JavaScript if we are not on the specified post/page.

1
2
global $post;
if (!isset($post->ID) || $post->ID != 123) return;
global $post;
if (!isset($post->ID) || $post->ID != 123) return;

Step 4

Save the file and upload it to your web server.

Enqueue scripts on multiple pages/posts

If you want to limit the plugin JavaScript and CSS to only appear on a few pages, the code is slightly different from above. Instead of checking against a single post ID we will check an array of post IDs.

Step 1

Get the IDs of the posts or pages that you want to display the Quform JavaScript/CSS on. You can find this number in the address bar when editing the post/page.

Step 2

Open the file iphorm-form-builder/includes/common.php and search for function iphorm_enqueue_styles(). This is the function that enqueues the CSS for the plugin. Inside this function, on the line below the opening curly bracket, add the code below. Note: replace the numbers inside the array below with your post IDs from Step 1. What this code does is prevents the plugin enqueuing the plugin CSS if we are not on the specified posts/pages.

1
2
global $post;
if (!isset($post->ID) || !in_array($post->ID, array(2, 15, 53, 89))) return;
global $post;
if (!isset($post->ID) || !in_array($post->ID, array(2, 15, 53, 89))) return;

Step 3

In the same file, search for function iphorm_enqueue_scripts(). This is the function that enqueues the JavaScript for the plugin. Inside this function, on the line below the opening curly bracket, add the code below. Note: replace the numbers inside the array below with your post IDs from Step 1. What this code does is prevents the plugin enqueuing the plugin JavaScript if we are not on the specified posts/pages.

1
2
global $post;
if (!isset($post->ID) || !in_array($post->ID, array(2, 15, 53, 89))) return;
global $post;
if (!isset($post->ID) || !in_array($post->ID, array(2, 15, 53, 89))) return;

Step 4

Save the file and upload it to your web server.

Note: if you update the plugin it will overwrite any changes you make to this file, so you will need to make the change again.

Still having trouble? Head over to the forums.

Forums