This topic contains 3 reply and 2 voices, and was last updated by Nathan 6 years, 6 months ago
Viewing 3 Posts - 1 through 3 (of 3 total)
Author Posts
April 7, 2013 at 10:11 am 1869
Nathan Is there a way to check with a php if statement to check if a form field is not filled in. I have created an address form and "address line 2" is not required. Because the address has a comma and a line break at the end of each line, if Address Line 2 is not filled in I would also need to hide the comma and line break. For example, I want to show: 31 Beet Route, Some town, Some county, DY8 2HQ NOT 31 Beet Route, , Some town, Some county, DY8 2HQ
April 7, 2013 at 10:52 am 1872
Tareq Hasan Tareq Hasan

Check the meta value existence like this:
[php]
if ( $address2 = get_post_meta( $post->ID, ‘address2’, true ) ) {
echo $address2;
}
[/php]

April 7, 2013 at 12:17 pm 1875
Nathan Nathan

That has worked for one, but not for another:

<?php if ( $restrictions = get_post_meta( $post->ID, ‘restrictions’, true ) ) { echo ‘<dt>Restrictions</dt><dd>’; $restrictions; ‘</dd>’; } ?>

Any thoughts?

April 7, 2013 at 1:15 pm 1876
Nathan Nathan

Fixed it… It was another  global $post; issue!

Viewing 3 Posts - 1 through 3 (of 3 total)