[英]WordPress, Parse Shortcode within Shortcode
我正在为一个运行社交赎金风格博客的客户创建一个网站。 这是用户必须单击社交媒体按钮之一才能访问内容的地方。
但是,她现在将对Wordpress使用OnePress Social Locker插件,该插件通过将内容包装在特定标签中来工作,如下所示:
[sociallocker] Content Here will Be Locked [/sociallocker]
目前,她已经有自己的自定义简码,其工作方式如下:
[socialLock url="http://example.com" text="Click here to view content"] Content here will be locked [/socialLock]
问题是她在博客上拥有2300多个页面,并且要更改每一个indv。 通过仪表板将需要很长时间,这不是按小时支付的合同。
我认为我可以将当前的简码传递给新的简码,如下所示:
function parseShortcode_func( $atts ) {
$atts = shortcode_atts( array(
'link' => '',
'text' => 'default text'
), $atts );
return "[sociallocker] <a href=\"{$atts['link']}\">{$atts['text']}</a> [/sociallocker]";
}
add_shortcode( 'socialLock', 'parseShortcode_func' );
但是那只是输出
[sociallocker] Click here to view content [/sociallocker]
有谁知道如何在简码中解析第二个简码?
do_shortcode()
函数将重新解析您的输出字符串。
return do_shortcode("[sociallocker] <a href=\"{$atts['link']}\">{$atts['text']}</a> [/sociallocker]");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.