Php WordPress短代码中的短代码
使用ultimate shortcodes插件(lightbox shortcode)和一些自定义样式,我经常在我的网站上创建弹出窗口。我试图通过在自定义短代码中包含短代码和自定义样式来简化用例 例如,这是我需要键入的代码,以获得所需的效果:Php WordPress短代码中的短代码,php,jquery,wordpress,shortcode,Php,Jquery,Wordpress,Shortcode,使用ultimate shortcodes插件(lightbox shortcode)和一些自定义样式,我经常在我的网站上创建弹出窗口。我试图通过在自定义短代码中包含短代码和自定义样式来简化用例 例如,这是我需要键入的代码,以获得所需的效果: <p style="text-align: left;">[su_lightbox type="inline" src=".123"]Some Name<i class="fa fa-chevron-right float-right"&
<p style="text-align: left;">[su_lightbox type="inline" src=".123"]Some Name<i class="fa fa-chevron-right float-right"></i>[/su_lightbox]</p>
<div class="123 mfp-hide">
This is the content
</div>
[su_lightbox type=“inline”src=“.123”]一些名称[/su_lightbox]
这就是内容
这是我试图将上述内容转换为短代码的尝试:
// Add Shortcode
function person_shortcode( $atts , $content = null ) {
// Attributes
extract( shortcode_atts(
array(
'name' => 'name',
'numb' => 'numb',
), $atts )
);
// Code
return '<p style="text-align: left;">[su_lightbox type="inline" src=".'.$numb'"]'. $name .'<i class="fa fa-chevron-right float-right"></i>[/su_lightbox]</p>
<div class="'. $numb .' mfp-hide">
'. $content . '
</div>';
}
add_shortcode( 'person', 'person_shortcode' );
//添加短代码
函数person\u短代码($atts,$content=null){
//属性
提取(短码)(
排列(
“名称”=>“名称”,
“麻木”=>“麻木”,
),$atts)
);
//代码
返回“[su_lightbox type=“inline”src=“.$numb]”.$name.[/su_lightbox]
“.$content。”
';
}
添加_短代码(‘person’、‘person_短代码’);
因此,我的问题是,我如何才能使上述工作
到目前为止,我已经尝试用Firebug内部的输出替换su_lightbox
shortcode,但是这不起作用。您可以手动调用shortcode回调返回的字符串。类似于以下的方法应该可以工作:
// Add Shortcode
function person_shortcode( $atts , $content = null ) {
// Attributes
extract( shortcode_atts(
array(
'name' => 'name',
'numb' => 'numb',
), $atts )
);
// Code
return do_shortcode( '<p style="text-align: left;">[su_lightbox type="inline" src=".'.$numb.'"]'. $name .'<i class="fa fa-chevron-right float-right"></i>[/su_lightbox]</p>
<div class="'. $numb .' mfp-hide">
'. $content . '
</div>' );
}
add_shortcode( 'person', 'person_shortcode' );
你可能是有意的:
src=".'.$numb.'"]'
我已经在上面的示例中解决了这个问题。似乎仍然不起作用。在我添加它之后,整个网站都变成了空白?有什么建议吗?@LukaDadiani代码中有一个语法错误,我已经修复了。谢谢,但它需要一个点来表示它链接到一个类?e、 g[su_lightbox type=“inline”src=“.class_name”]教授亚历克·布罗斯勋爵[/su_lightbox]
src=".'.$numb.'"]'