WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] PHP syntax is jacked. Using custom fields in a unique way (4 posts)

  1. jcprovideo
    Member
    Posted 5 years ago #

    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; ?>
  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    if $jobtype = 'web'

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

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

  3. jcprovideo
    Member
    Posted 5 years ago #

    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; ?>
  4. jcprovideo
    Member
    Posted 5 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic