开发者

Getting a value using WordPress custom fields

开发者 https://www.devze.com 2023-03-06 14:13 出处:网络
I am trying to output demo and download links for posts using custom fields i开发者_开发问答f its required.

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

精彩评论

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