duangua6912 2014-10-17 13:47
浏览 48
已采纳

从文本区域插入的Wordpress短代码中删除引号

I've added shortcode to a page via a custom textarea in my Wordpress admin, but the shortcode is seen as text and gets wrapped in quotation marks, so it doesn't work.

enter image description here

This is basically how I sanitize my input:

if( isset( $input['textarea_input'] ) )
        $new_input['textarea_input'] = sanitize_text_field( $input['textarea_input'] );

This is how I output it on the page:

<?php echo $options['textarea_input']; ?>

do_shortcode does not change anything

<?php echo do_shortcode($options['textarea_input']); ?>

My guess is that the Wordpress TinyMCE editor recognizes shortcode, and therefor it works. Since mine is added via a hidden text area, it's just seen as plain text. What does the TinyMCE editor what I'm not doing? I wan't

  • 写回答

1条回答 默认 最新

  • douyou1857 2014-11-08 00:22
    关注

    Your sort of right, the Wordpress editor saves content thru a filter called the_content. This filter is used to filter the content of the post after it is retrieved from the database and before it is printed to the screen. Apply this filter to simulate TinyMCE formatting.

    <?php echo apply_filters( 'the_content', $options['textarea_input']); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?