theme development - Wpautop in wp_editor not working

I recently added a custom meta box with Tinymce support. I wanted to output the data as html. If I code p tags manually

I recently added a custom meta box with Tinymce support. I wanted to output the data as html. If I code p tags manually inside Tinymce it works. But if I switch to Visual mode, the p tags aren't automatically added.

I used the wpautop argument inside wp_editor but it didn't work. How may the paragraphs be automatically added?

I recently added a custom meta box with Tinymce support. I wanted to output the data as html. If I code p tags manually inside Tinymce it works. But if I switch to Visual mode, the p tags aren't automatically added.

I used the wpautop argument inside wp_editor but it didn't work. How may the paragraphs be automatically added?

Share Improve this question edited Apr 5, 2019 at 13:44 cjbj 15k16 gold badges42 silver badges89 bronze badges asked Apr 5, 2019 at 10:12 Anita DesaiAnita Desai 11 silver badge1 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 2

Normally, the wpautop filter is only applied to the_content and the_excerpt. In this case you want to apply it to metadata. So you'll have to add the filter.

If you look at get_post_meta, you'll see that it is just a wrapper for get_metadata. So it doesn't matter which one you use if you retrieve the content of the metabox. Unfortunately there is no filter call in there that you can use to modify what it returns.

So, that leaves you with the possibility to modify the metabox content after is has been retrieved. In stead of echo get_post_meta ($post_ID, $metabox_name) you would write echo wpautop (get_post_meta ($post_ID, $metabox_name))

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745624420a4636718.html

相关推荐

  • theme development - Wpautop in wp_editor not working

    I recently added a custom meta box with Tinymce support. I wanted to output the data as html. If I code p tags manually

    11小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信