admin管理员组文章数量:1431997
I have snipped of PHP code I'd like to have wrapped within its php-file with the do_shortcode function. Unfortunatly, I don't have clue how to do this. Several ways I tried end in an error on the page.
This is the code snipped I'd like to wrap:
<?php echo the_aiovg_player( $attributes['id'] ); ?>
And this is the wrapping shortcode that should cover it:
[pc-pvt-content allow="all" block="" warning="1" message="1" login_lb="" registr_lb=""][/pc-pvt-content]
So at the end it should look like this:
[pc-pvt-content allow="all" block="" warning="1" message="1" login_lb="" registr_lb=""]<?php echo the_aiovg_player( $attributes['id'] ); ?>[/pc-pvt-content]
How can I implement it in my php-code that it works?
I have snipped of PHP code I'd like to have wrapped within its php-file with the do_shortcode function. Unfortunatly, I don't have clue how to do this. Several ways I tried end in an error on the page.
This is the code snipped I'd like to wrap:
<?php echo the_aiovg_player( $attributes['id'] ); ?>
And this is the wrapping shortcode that should cover it:
[pc-pvt-content allow="all" block="" warning="1" message="1" login_lb="" registr_lb=""][/pc-pvt-content]
So at the end it should look like this:
[pc-pvt-content allow="all" block="" warning="1" message="1" login_lb="" registr_lb=""]<?php echo the_aiovg_player( $attributes['id'] ); ?>[/pc-pvt-content]
How can I implement it in my php-code that it works?
Share Improve this question asked Apr 18, 2019 at 7:06 EffectionEffection 11 Answer
Reset to default 0If pc-pvt-content
supports nested shortcodes, then I think you could wrap the_aiovg_player()
inside a custom shortcode. Something like this,
// In your theme functions.php
if ( ! shortcode_exists( 'the_aiovg_player' ) && function_exists( 'the_aiovg_player' ) ) {
function myprefix_the_aiovg_player_shortocode( $atts ) {
$id = ( ! empty( $atts['id'] ) && is_numeric( $atts['id'] ) ) ? intval( $atts['id'] ): 0;
if ( ! $id ) {
return '';
}
return the_aiovg_player( $id );
}
add_shortcode( 'the_aiovg_player', 'myprefix_the_aiovg_player_shortocode' );
}
Then you could use the custom shortcode like this,
[pc-pvt-content ..attributes.. ][the_aiovg_player id="123"][/pc-pvt-content]
本文标签: phpHow do I wrap this
版权声明:本文标题:php - How do I wrap this? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745575551a2664306.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论