• Resolved ff4500

    (@ff4500)


    I’m trying to get custom fields working with a php call in the loop. Here’s the code that I currently have, but I know isn’t working. The idea is that if there’s an image listed in the custom field in an entry, it will display on the post. If not, nothing prints. Here’ the code:

    <?php //get article_image (custom field) ?>
    <?php $image = get_post_meta($post->ID, 'article_image', true); ?>

    And the code for the entry:

    <?php if ($image) { print '<img class="article_image" src="<?php echo $image; ?>"><br /><br />'; } ?>

    The only problem is that it doesn’t actually print out the image url, the php echo call is always still in the code as not being parsed. Since I don’t know a whole lot about php, this is stumping me. Anyone care to take a gander?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter ff4500

    (@ff4500)

    btw – it’s inspired by this page

    Thread Starter ff4500

    (@ff4500)

    fixed it using this code (which is sort of clunky):

    <?php if ($image) { echo '<p><img class="article_image" src="'; } ?><?php echo $image; ?><?php if ($image) { echo '"></p>'; } ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom Field php’ is closed to new replies.