开发者

Wordpress Shortcodes and Conditional Statements

I am using custom shortcodes for my post editor and i now have multiple shortcodes i would like to make a shortode be stylized differently if another shortcode is enabled. Is开发者_高级运维 there a filter or conditional function like is_shortcode('slideshow') if not has anyone written a workaround for this?


There is no API for checking existing shortcodes, but its easy enough to check the global for what has been registered:

<?php
function my_shortcode($atts) {
    global $shortcode_tags;
    if (in_array('other-shortcode', $shortcode_tags)) {
        // ... do conditional logic
    }
}
add_shortcode('my-shortcode', 'my_shortcode');
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜