Getting a value using WordPress custom fields
I am trying to output demo and download links for posts using custom fields i开发者_开发问答f 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
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; ?>
精彩评论