我有这样的代码,它向有付费订阅的用户显示内容:
echo do_shortcode('[ihc-hide-content ihc_mb_who="5,7"] MY CONTENT HERE [/ihc-hide-content])
但是我想在这个短代码中显示,其中写着我的内容,一个逻辑函数,如下所示:
if ( $a = $b ) { echo ($c); }有可能以某种方式做到这一点吗?P.S.我又做了一个短代码,把他放在里面,就像这样:
do_shortcode('[ihc-hide-content ihc_mb_who="5,7"].do_shortcode('[my_shortcode]').[/ihc-hide-content])但是第一个短代码并不是隐藏第二个短代码的内容。任何帮助都会被接受,对我糟糕的英语表示歉意!
发布于 2019-02-06 18:50:54
如果您使用的是封闭式短码,您应该能够将这些短代码作为字符串添加到您的do_shortcode()函数中。do_shortcode()将搜索传递给它的内容,并解析出它能够解析的任何和所有的短代码。根据设置ihc-hide-content短代码的方式,它可能不能很好地工作,但您也可以绕过它。
首先,我只想将一个短代码字符串传递给它:
do_shortcode( '[ihc-hide-content ihc_mb_who="5,7"][my_shortcode][/ihc-hide-content]' );如果这不起作用(老实说,它应该起作用)--您可以尝试将my_shortcode的输出生成如下所示的输出缓冲器:
// Turn on Output Buffering
ob_start();
// Output your shortcode
do_shortcode( '[my_shortcode]' );
// Turn off Output Buffering, and grab the content as a variable
$my_shortcode_output = ob_get_clean();
// Pass that complete output to the other shortcode
do_shortcode( '[ihc-hide-content ihc_mb_who="5,7"]'. $my_shortcode_output .'[/ihc-hide-content]' );https://stackoverflow.com/questions/54559791
复制相似问题