doushi1473 2018-01-31 18:18
浏览 73
已采纳

将Wordpress函数嵌套在函数内的短代码中

I need to use a plugin shortcode within a template file, but have one of the variables be set by the value of a custom field in the post. Here's what I have so far. This just breaks the entire page.

My effort (not working):

<?php echo do_shortcode('[wpsp pls_id="get_post_meta($post->ID, 'playlist', true)"]'); ?>

The shortcode:

[wpsp pls_id="NEED VALUE SET HERE"]

The custom field function:

<?php echo get_post_meta($post->ID, 'playlist', true); ?>

Thanks.

  • 写回答

1条回答 默认 最新

  • douqiao5552 2018-01-31 18:36
    关注

    Try this:

    <?php echo do_shortcode('[wpsp pls_id="' . get_post_meta($post->ID, 'playlist', true) . '"]'); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?