2016-08-17 25 views
0

我有一个简码获取简码内容是

[my_shortcode param1="Parameter 1"]The content here adds 
br tag here and converts my quotes 'like this' to html 
but does not touch double quotes "somehow"[/my_shortcode] 

我想获得我的简码的内容是,没有BR标签,p标签和HTML实体转换单引号或其他一些惊喜。

有没有一种方法来获取短代码内容?

预先感谢您...

回答

1

如果你的意思是你想要的解析简码:

$content = do_shortcode('[my_shortcode]foobar[/my_shortcode]'); 

获取内容“原样”你需要逆向工程的WordPress怎么做的转换。通常所见即所得的内容WordPress通过一些功能运行内容:wpautopwp_texturizewpautop添加了p标签,wp_texturize进行了一般清理和字符转换。

看看这些功能,看看你如何才能扭转他们所做的事情。其中一个就是使用strip_tags()html_entity_decode()以尽最大努力。