php - How to get a wordpress post custom filed value and assign it to a variable? -
I am creating a form that sends the details of the form to my email.
My custom field is:
My Function Php and my form is: But when the form is submitted, contact me at the If I use hidden fields for it then it works fine Has been: As I mentioned, take a look at the lower area of the question hidden field. Change the function with the following code:
function getHotel_contact_number () {global $ wp_query; $ Postid = $ wp_query- & gt; Post- & gt; Id; $ GetHotel_contact_number = get_post_meta ($ postid, 'hotel_contact_number', true); $ GetHotel_contact_number; }
& lt; PHP $ errors = array (); If (isset ($ _ POST ["submit"])) {$ to = "myemail@email.com"; $ Theme = "this is my subject"; $ Hotels = meet (); $ Hotel_contact_nmbr = getHotel_contact_number (); Check out the $ header = array ('sender email'). '' & Gt; ';' // and make sure it is not a blank / empty string. If (empty ($ sender)) {// string down empty, Error Errors $ Error Adding $ Errors ['Sender User'] = "Please Enter Your Name!" If (empty ($ Sender Email)) {// empty string, error errors $ add errors $ errors ['Sender e-mail'] = "Please enter your email!" $} Mailbox D = "& lt; h3> Hotel details & lt; / h3 & gt; & lt; br / & gt; $ hotel & lt; br / & gt; $ hotel_contact_nmbr
" $ Mail_sent = wp_mail ($ $ $ $ theme, $ mailbox, $ header);} if ($ mail_st) {? & Gt; & lt; h1 style = "color: # 007f00;" & gt; request sent. Lt; / h1 & gt; & lt ;? php} and {? & Gt; & lt; form id = "" name = "" action = "& lt ;? php echo get_permalink ();? & Gt; method = "Post"> hotel contact number For Val is getting blank value. Am I wrong? How can I get the right custom filed value if the form is submitted?
function getHotel_contact_number () {global $ wp_query; $ Postid = $ wp_query- & gt; Post- & gt; Id; $ GetHotel_contact_number = get_post_meta ($ postid, 'hotel_contact_number', true); Refund $ getHotel_contact_number; }
Comments
Post a Comment