开发者

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; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜