- This topic has 4 replies, 2 voices, and was last updated 4 years ago by David.
-
AuthorPosts
-
April 2, 2020 at 4:56 pm #1224242michael
I have successfully entered the the html of my home page in my home page generatepress html editor, including displayed text.
Everything works fine.
I try to add more text using simple php statement: “<?php echo “Hi there.”; ?>”
Nothing displays… PLEASE HELP!!! I am new to WordPress, I must understand this before I can create my own Form.
I am testing to be able to create my own Contact Form using generatepress.com suggestion:
“https://premium.wpmudev.org/blog/how-to-build-your-own-wordpress-contact-form-and-why/”… the php statements are not being processed.
Thanks,
Michael
April 2, 2020 at 7:02 pm #1224317michael(this is an addition to my above post)
…I am trying to create a “Contact Form” on my Home Page, as only one of several parts on my page.
On this Home Page I have 1) Hero, 2) Text, 3) Text, 4) Text, 5) Contact Form, 6) About.
I do not want to a separate page for my “form”.
How do I do this using GeneratePress, Mellow SiteLibrary child theme?
Thanks,
Michael
April 3, 2020 at 4:26 am #1224662DavidStaffCustomer SupportHi there,
WordPress will not execute PHP that is added via the editor.
Instead you could call your template using a Shortcode. Example function for creating shortcode:
function your_form_shortcode() { ob_start(); get_template_part('your_form_template'); return ob_get_clean(); } add_shortcode( 'form_shortcode', 'your_form_shortcode' );
April 3, 2020 at 7:05 am #1224847michael(Michael from above, more details on my issue)
My “Contact Form” HTML code on my Home Page that is not working
(Note that this is not a separate form page, but rather a Form Section on my Home Page.
This is a direct copy from “https://premium.wpmudev.org/blog/how-to-build-your-own-wordpress-contact-form-and-why/” begining with line “<style type=”text/css”>”I am not getting an actual error number, rather the PHP code is not being substituted for values and instead the PHP statement is being displayed along with labels.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<span id=”signup-title” class=”section-title”>Signup</span>
<hr id=”signup-title-underline”><p>• Sign-up is Optional.</p>
<p>• All Fields are Optional.</p>
<p>• The more info you give, the more you can help IMPROVE the game.<br>
–THANK YOU</p>
<p>• If you would like to receive Email, you must enter your Email Address.</p><style type=”text/css”>
.error{
padding: 5px 9px;
border: 1px solid red;
color: red;
border-radius: 3px;
}.success{
padding: 5px 9px;
border: 1px solid green;
color: green;
border-radius: 3px;
}form span{
color: red;margin-left: 30% !important;
}
</style><?php echo $response; ?>
<form action=”<?php the_permalink(); ?>” method=”post”>
<p><label for=”name”>Name: <input type=”text” name=”message_name” value=”<?php echo esc_attr($_POST[‘message_name’]); ?>”></label></p>
<p><label for=”message_email”>Email: <input type=”text” name=”message_email” value=”<?php echo esc_attr($_POST[‘message_email’]); ?>”></label></p>
<p><label for=”message_text”>Message: <textarea type=”text” name=”message_text”><?php echo esc_textarea($_POST[‘message_text’]); ?></textarea></label></p>
<p><label for=”message_human”>Human Verification: <input type=”text” style=”width: 60px;” name=”message_human”> + 3 = 5</label></p>
<input type=”hidden” name=”submitted” value=”1″>
<p><input type=”submit”></p>
</form>April 3, 2020 at 11:24 am #1225423DavidStaffCustomer SupportAs i said – you cannot add PHP to the editor – WordPress will NOT execute it.
If you create the template as that article explains you can then use the Shortcode i provided to call that template. -
AuthorPosts
- You must be logged in to reply to this topic.