theme/plug PHP编码中的Wordpress进程[括号标签]
Wordpress process [bracket tag] in theme/plug PHP coding
我最近在 Wordpress 上安装了 Revolution Slider,创建了一个包含 3 个示例图像的滑块,并通过在内容部分添加以下字符串将其安装在页面上:
[rev_slider nonimage1]
<!-- note: other HTML before and after works OK too -->
然后在页面加载时对其进行解析,滑块加载并正常工作。
但是,在 /wp-admin 中,如果我转到 Appearance > Themes
并按如下方式编辑其中一个 PHP 页面:
//break out of php here...
?>
[rev_slider nonimage1]
<?php
//and back in we go...
括号内的字符串(编辑:我理解为 "shortcode")未被处理。
由于我是 Wordpress 的新手,我仍在研究处理顺序,但是是否有与 HTML 内容部分中使用的方法类似的 WP 等效处理器方法,我可以在此处应用?类似于:
WP_God_Class::processThis('[rev_slider nonimage1]');
"Bracketed string" - 标签,未处理,因为它必须从短代码操作中调用。 TinyMCE 和 the_content() 自动执行。
如果您要在文件中回显简码结果,请使用
<?php echo do_shortcode( '[rev_slider nonimage1]' ) ?>
如果你要从 HTML 中解析标签,这似乎是不可能的,因为它必须在 PHP 中转换。
或者,如果您从包装的 HTML 中解析它,它应该可以与
一起使用
<?php
$content = 'abc <br> [rev_slider nonimage1] def';
echo apply_filters( 'the_content', $content );
?>
我最近在 Wordpress 上安装了 Revolution Slider,创建了一个包含 3 个示例图像的滑块,并通过在内容部分添加以下字符串将其安装在页面上:
[rev_slider nonimage1]
<!-- note: other HTML before and after works OK too -->
然后在页面加载时对其进行解析,滑块加载并正常工作。
但是,在 /wp-admin 中,如果我转到 Appearance > Themes
并按如下方式编辑其中一个 PHP 页面:
//break out of php here...
?>
[rev_slider nonimage1]
<?php
//and back in we go...
括号内的字符串(编辑:我理解为 "shortcode")未被处理。
由于我是 Wordpress 的新手,我仍在研究处理顺序,但是是否有与 HTML 内容部分中使用的方法类似的 WP 等效处理器方法,我可以在此处应用?类似于:
WP_God_Class::processThis('[rev_slider nonimage1]');
"Bracketed string" - 标签,未处理,因为它必须从短代码操作中调用。 TinyMCE 和 the_content() 自动执行。
如果您要在文件中回显简码结果,请使用
<?php echo do_shortcode( '[rev_slider nonimage1]' ) ?>
如果你要从 HTML 中解析标签,这似乎是不可能的,因为它必须在 PHP 中转换。
或者,如果您从包装的 HTML 中解析它,它应该可以与
一起使用<?php
$content = 'abc <br> [rev_slider nonimage1] def';
echo apply_filters( 'the_content', $content );
?>