dqrqp8492 2015-08-17 10:53
浏览 74
已采纳

PHP短代码输入变量

I'm displaying a gallery on my wordpress site using the following code:

<?php echo do_shortcode('[satellite gallery=2 auto=off caption=off thumbs=on]'); ?>

Now I've added a custom post value/field called 'guitLink' where I can add the gallery number which I want to then use in the above shortcode, so something like this:

<?php echo do_shortcode('[satellite gallery=' .get_post_custom_values('guitLink'). 'auto=off caption=off thumbs=on]'); ?>

Any ideas how to achieve this?

  • 写回答

1条回答 默认 最新

  • dpd7195 2015-08-17 10:59
    关注

    Use:

    <?php $guitLink = get_post_custom_values('guitLink');
    echo do_shortcode('[satellite gallery=' .$guitLink[0]. ' auto=off caption=off thumbs=on]'); ?>
    

    Instead of

    <?php echo do_shortcode('[satellite gallery=' .get_post_custom_values('guitLink'). ' auto=off caption=off thumbs=on]'); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?