• hello there,

    i have been trying to write code that will only display address information if that custom field is present. everytime i try to enter an “if” statement i get an error… I want the address and contact information to display only for a certain category and not for others.i currently have:

    <?php
    //Gets post-meta info

    if(get_post_meta($post_id, Course_Address, true);
    get_post_meta($post_id, Course_City, true);
    get_post_meta($post_id, Course_State, true);
    get_post_meta($post_id, Course_Postcode, true);
    get_post_meta($post_id, Course_Contact_Number, true);
    get_post_meta($post_id, Course_Holes, true);
    get_post_meta($post_id, Course_Length, true);
    get_post_meta($post_id, Course_Par, true))
    { ?>
    <p><b>Address: </b><?php echo get_post_meta($post->ID, Course_Address, true); ?>, <?php echo get_post_meta($post->ID, Course_City, true); ?>, <?php echo get_post_meta($post->ID, Course_State, true); ?> <?php echo get_post_meta($post->ID, Course_Postcode, true); ?>
    <b>Contact Number: </b><?php echo get_post_meta($post->ID, Course_Contact_Number, true); ?>
    <b>Holes: </b><?php echo get_post_meta($post->ID, Course_Holes, true); ?>
    <b>Length: </b><?php echo get_post_meta($post->ID, Course_Length, true); ?>
    <b>Par: </b><?php echo get_post_meta($post->ID, Course_Par, true); ?></p>
    <?php } ?>

    This does not limit to categories, i imagine i will have to make a statement like if category ” then get…?

  • The topic ‘Insert text with Custom Fields ONLY when present’ is closed to new replies.