我不确定我的问题是否有一个简单的解决方案。这个要求看起来很简单,但即使在我头破血流了6个小时后也找不到答案。我必须将变量从php函数传递到一个短代码,而这个短代码必须将这个变量传递到另一个短代码。Shortcode-1将打开一个弹出窗口,弹出窗口的内容由Shortcode-2创建,内容必须根据变量进行更改。我怎样才能做到这一点?
我的模板中的代码。。
<a href="#" class="open-popup-1" variable= <?php getid(); ?>"> <?php echo "Click here"?> </a>
弹出式快捷码:[modifycontent id=$variable]
My shortcode函数function modifycontent($atts = [], $content = null)
{
// do something to $content
$var = atts[\'id\'];
$content = gettherightcontent($var);
return $content;
}
add_shortcode(\'mc\', \'modifycontent\');
我试着这样做,我设法调用了我的短代码,但无法传递变量。