• Resolved HorrorUK

    (@horroruk)


    I have the following code, but it doesn’t seem to be working correctly:

    <?php if( get_post_meta($post->ID, "Image", true) ): ?>
    <img src="<?php echo $Image; ?>"><br />
    <P>
    <?php wswwpx_content_extract ( ' ', 45, 45 ); ?>
    <?php else: ?>
    <?php the_content(); ?>
    <?php endif; ?>

    It looks like it should work, but the image doesn’t show up, though the text from the extract does work.

    The content does show up if there is no ‘Image’ custom field.

Viewing 2 replies - 1 through 2 (of 2 total)
  • vtxyzzy

    (@vtxyzzy)

    This should work:

    <?php if( $image = get_post_meta($post->ID, "Image", true) ): ?>
    <img src="<?php echo $image; ?>"><br />
    <P>
    <?php wswwpx_content_extract ( ' ', 45, 45 ); ?>
    <?php else: ?>
    <?php the_content(); ?>
    <?php endif; ?>

    but you seem to be missing a </p> tag.

    Thread Starter HorrorUK

    (@horroruk)

    Thanks, that worked great. I didn’t really need the <p>, so just got rid of it.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Custom field with if/else’ is closed to new replies.