0

I am trying to output demo and download links for posts using custom fields if its required.

Here is the sample code

<?php if( get_post_meta($post->ID, "demo", true) : ?> <a href="<?php the_permalink() ?>" rel="bookmark"> <div class="demo" src="<?php echo get_post_meta($post->ID, "demo", true) ?>" alt="<?php the_title(); ?>" /> </a> <?php endif; ?>

Help me, whats making wrong with this code

1
  • What is the problem? What doesn't work? Commented May 15, 2011 at 20:30

1 Answer 1

1

You're missing a closing bracket in your if statement... Try this instead:

<?php if( get_post_meta($post->ID, "demo", true)) : ?> 
    <a href="<?php the_permalink() ?>" rel="bookmark"> 
        <img class="demo" src="<?php echo get_post_meta($post->ID, "demo", true) ?>" alt="<?php the_title(); ?>" />
    </a>
<?php endif; ?>
Sign up to request clarification or add additional context in comments.

1 Comment

Also, I believe your div should be an img tag... you might want to correct that as well. (edited above as well)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.