WordPress功能函数apply_shortcodes()

WordPress功能函数apply_shortcodes(),搜索内容的短码和过滤短码通过他们的钩子。

用法:

apply_shortcodes( string $content, bool $ignore_html = false )

描述

这个函数是do_shortcode()的别名。

参见also

do_shortcode ()

参数:

$content

(string) (必需) 搜索短码的内容。

$ignore_html

(bool) (可选) 当为true时,HTML元素内的短代码将被跳过。

默认值: false

返回

(string)过滤掉的短码内容。

来源

文件: wp-includes/shortcodes.php

function apply_shortcodes( $content, $ignore_html = false ) {

return do_shortcode( $content, $ignore_html );

}

更新日志:
WordPress功能函数apply_shortcodes() (https://www.wp-admin.cn/) WordPress开发教程 第1张
用户贡献的笔记

(由MakeWebBetter贡献- 11个月前)

下面是当前方法-的实现

echo do_shortcode( ‘[myshrtcode]My Text[/myshrtcode]’ );

下面是新WordPress 5.4引入的用法

echo apply_shortcodes( ‘[myshrtcode]My Text[/myshrtcode]’ );

// Displays the result of the shortcode

(由Ataur R – 9个月前贡献)

老方法-

echo do_shortcode( ‘[wpdocs_my_shrtcode text=”My Text”]’, false );

echo do_shortcode( ‘[wpdocs_my_shrtcode]My Text[/wpdocs_my_shrtcode]’, false );

WordPress 5.4引入apply_shortcodes()

echo apply_shortcodes( ‘[wpdocs_my_shrtcode text=”My Text”]’, false );

echo apply_shortcodes( ‘[wpdocs_my_shrtcode]My Text[/wpdocs_my_shrtcode]’, false );

//显示短码的结果

相关推荐

发表回复

房先生
我们将24小时内回复。
2024-07-15 06:30:28
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
[QQ客服]
2781198
加我微信
[电话联系]
13585372227
[电子邮件]
chaoneo@163.com
取消

选择聊天工具: