WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] PHP syntax is jacked. Using custom fields in a unique way

[Resolved] PHP syntax is jacked. Using custom fields in a unique way

  • My syntax is jacked. I tried to use custom fields in an interesting way but I jacked it all up.

    Basically I want to display specific PHP (<?php insert_cform (‘6’) ; ?>) based on what was written in the custom field. I am hoping my logic was somewhat correct, but I just messed up the syntax. I am more of a CSS guy so any help would be appreciated.

    <?php $jobtype = get_post_meta($post->ID, 'job-type', true);  ?>
           <?php
           		if $jobtype = 'web' { $jobresumetype = '<?php insert_cform ('4') ; ?>' };
    					elseif $jobtype = 'design'{ $jobresumetype = '<?php insert_cform ('5') ; ?>' };
    					else if $jobtype = 'copy'{ $jobresumetype = '<?php insert_cform ('6') ; ?>' };
    				else $jobresumetype = '' };
    					?>
    
              <?php echo $jobresumetype; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • if $jobtype = 'web'

    Wrong. Try this:
    if ($jobtype == 'web')

    Ditto for the other if statements. Also, “elseif” is two words.

    Thanks OTTO42

    Humm I still got problems though. this is what I have now. It is always pulling insert_cform (‘4’)

    <?php
           		if ($jobtype == 'web' ) {
    					$jobresumetype = insert_cform ('4') ;
    				}  elseif ($jobtype == 'design') {
    					$jobresumetype = insert_cform ('5') ;
    				}	elseif ($jobtype == 'copy') {
    					$jobresumetype = insert_cform ('6') ;
    				}	else {
    					$jobresumetype == '' ;
    				}
    					?>
              <?php echo $jobresumetype; ?>

    Nevermind…I got it working. I had this:
    <?php $jobtype = get_post_meta($post->ID, ‘job-type’, true); ?>
    in the wrong place. Thanks for your help!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] PHP syntax is jacked. Using custom fields in a unique way’ is closed to new replies.