Products
GG网络技术分享 2025-03-18 16:12 13
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.
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议我需要在模板文件中使用插件短代码,但其中一个变量是由值设置的 帖子中的自定义字段。 这是我到目前为止所拥有的。 这只会打破整个页面。</ p>
我的努力(不工作):</ p>
&lt;?php echo do_shortcode(\'[wpsp pls_id =“get_post_meta($ post-&gt; ID,\'playlist\',true)”]\'); ?&gt; </ code> </ pre>
短代码:</ p>
[wpsp pls_id =“需要在此设置值”] </ code> </ pre>
自定义字段函数:</ p>
&lt;?php echo get_post_meta($ post-&gt; ID,\'播放列表 \',真实); ?&gt; </ code> </ pre>
谢谢。</ p>
</ div>
网友观点:
Try this:
<?php echo do_shortcode(\'[wpsp pls_id=\\\"\' . get_post_meta($post->ID, \'playlist\', true) . \'\\\"]\'); ?>
Demand feedback