Js popup window with form. WordPress feedback form: we create quickly and efficiently. Source code for calling the form and handler

Hello dear reader, in this article I will show you how to create a form feedback in a popup on your WordPress site. Often, when developing your own website or blog, it is necessary to establish the ability to quickly communicate with visitors to an Internet resource. In this case, the pop-up feedback form for WordPress will come in handy, which will help to establish quick contact with users.

Why do you need a pop-up feedback form for WordPress? Reasons for using it

Let's look at why this form is needed

  • Saving free space Online. The contact form can be placed anywhere: in the footer or header, in the main content of the page, as a floating button, etc.
  • Effective appearance. The animation of the appearance of a new window looks interesting and unusual
  • Availability. You can leave entries in this form from anywhere on the site; users do not need to return to the main page.
  • An added bonus: the form is easy to modify and customize to suit the needs of your site. A pop-up feedback form for WordPress can be presented in the form of an opening window for ordering a call, service or product, or making a subscription. If desired, you can add visual effects, various images etc.

    Plugins for installing a popup form

    Let's take a look at the tools required to develop popups in wordpress - special application for development and creation of websites.

    Contact Form 7

    This plugin is used directly to design the form. To install it, follow these steps:

    Easy FancyBox

    This plugin is suitable for developing a pop-up window effect. The Easy FancyBox installation sequence is similar to the previous plugin installation.

    Setting up plugins

    You can configure the settings of the Easy FancyBox add-on through media files. Use the menu options “Settings” -> “Media files”.

    In the block that opens just below standard settings The parameters of the plugin itself will be located. There is usually a checkmark next to the “Images” item, which indicates that a pop-up window will be activated when you click on the image. It is advisable to remove it, since if there are other additional tools creating a popup animation will occur double opening images.

    But that is not all. Check the box next to “Inline content”

    Anyone can further delve into the plugin’s settings and set them to their own discretion.

    Tip: if you want the form to always be open, then uncheck Easy settings FancyBox checkbox next to the “Close FancyBox when overlay is clicked” option, which performs the function of closing the window when the mouse is clicked outside of it.

    Step-by-step instruction

    Well, with “boring” preliminary preparation That's it, now let's move on to the “tasty” part - how, in fact, the WordPress pop-up feedback form is developed.

    Handling the Form Window

    Where do we start? Of course, with preset the form itself. Select “Contact Form 7” in the right menu, and then the “Add new” option.

    Come up with a new name for the form, for example, “Experiment,” enter it into the input field of the window that opens, where the text “Title” is located, and click on the “Save” button. You can change other parameters, including the form template itself, but we won’t touch it. Now ours the main objective– just learn how to create pop-up forms.

    Take a look at the result. As you can see, the plugin generated a special shortcode that is used to subsequently display the form. You need to copy it.

    Form output

    Now let's get down to programming. New program code can be inserted anywhere on the site, for example, in “Contacts”, and others. In our example new form will be displayed in the widget. Select from the menu sequentially " Appearance", then click on "Widgets", then in the window that opens, click on the "Text" option.

    Now click on the “Add Widget” button

    Paste the following code into the Content input field:

    Write a letter Starting text Ending text

    This is what the resulting result will look like:

    Please note that instead of the shortcode specified in the example, you will need to specify the one that you created as a result of creating a new form.

    Additionally, the form can be edited: add or remove input fields, enter initial and/or ending text before and after the form, convert the text into a title or display it as a separate block, use different styles, placeholders, etc. If only there was time and desire!

    Link styling

    Let's also look at two ways to convert a link into a button to improve its visual appearance.

    Method 1: Using additional theme styles.

    The following code can be inserted as follows:

    The program code itself looks like this:

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 /***Displaying a link in a button form****/ .contact-us a( margin:auto; /*aligning the block in the center*/ display:block; width:199px; /*button size*/ padding:11px 22px ; /*inner padding*/ border:1px solid black; /*border shade*/ background:#3399ff; /*background pattern*/ text-decoration:none; /*text-align:center; /*centering the caption*/ color:#ffffff; /*color of the caption*/ -moz-transition: all 0.6s ease; -webkit-transition: all 0.6s ease; transition: all 0.6s ease) /**Change the color links when hovering the cursor**/ .contact-us a:hover( -moz-box-shadow: 0 0 7px #111; -webkit-box-shadow: 0 0 7px #111; box-shadow:0 0 7px #111 ; -moz-transition: all 0.6s ease; -webkit-transition: all 0.6s ease;

    /***Displaying a link in a button form****/ .contact-us a( margin:auto; /*aligning the block in the center*/ display:block; width:199px; /*button size*/ padding:11px 22px ; /*inner padding*/ border:1px solid black; /*border shade*/ background:#3399ff; /*background pattern*/ text-decoration:none; /*text-align:center; /*centering the caption*/ color:#ffffff; /*color of the caption*/ -moz-transition: all 0.6s ease; -webkit-transition: all 0.6s ease; transition: all 0.6s ease) /**Change the color links when hovering the cursor**/ .contact-us a:hover( -moz-box-shadow: 0 0 7px #111; -webkit-box-shadow: 0 0 7px #111; box-shadow:0 0 7px #111 ; -moz-transition: all 0.6s ease; -webkit-transition: all 0.6s ease;

    The result is a button like this:

    The code already says which parameter is responsible for what. Now everyone can edit the code to their liking, experimenting with different styles and colors and creating the most suitable link for the popup.

    Method 2 – use an image as a button. First, upload the required image to the site (any image you like, not necessarily in the form of a button - it doesn’t really matter). To do this, click on “Media” -> “Add New” and select the desired picture. A permanent link to the file will appear to the right of the image (in in this example http://www.sait.ru/wp-content/uploads/2017/04/depositphotos_2169498-E-mail-internet-icon.jpg), copy it and add it to the code (do not remove the quotes):

    Add the resulting code to the main output code of the form instead of the text “Write a letter”.

    1

    My website displayed the button shown in the screenshot below:

    And this is what the button will look like if you leave the additional style described in the first method:

    Add to menu

    So that the pop-up feedback form for WordPress can be called directly from the menu, you must use the following code

    1 2 3
  • Write a letter
  • Write a letter
  • First you need to figure out where exactly you need to insert this code. Go to the “Editor” through “Appearance” and among the templates select “Header (header.php)”

    Now find the place where the menu code is located. Find the following information:

    1 2