Greeting
I have a problem, I would like to create a form on wordpress manually but I cannot attach a php file to my wordpress page.
How to do ?
Greeting
I have a problem, I would like to create a form on wordpress manually but I cannot attach a php file to my wordpress page.
How to do ?
2
Answers
There are several ways to achieve this.
Create a child-theme from your theme and then create an individual template for the form (https://developer.wordpress.org/themes/advanced-topics/child-themes/). If the form is a page, then just copy the page.php file to the childtheme, renamte ist to page-form.php and then edit it. See https://developer.wordpress.org/themes/template-files-section/page-template-files/ for more information. Afterwards you can change the template in wordpress. Do not forget to sanitize form inputs (https://developer.wordpress.org/themes/theme-security/data-sanitization-escaping/)
Install a form plugin
This is the solution I would prefer if your usecase allows this. I am using wpforms, but I have not checked for alternative plugins the last two years. There may be others that could work for you better.
Create a shortcode for the PHP code, then paste the shortcode on the page where you want to put the form.
Reference: