最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Wpautop in wp_editor not working

programmeradmin2浏览0评论

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))

发布评论

评论列表(0)

  1. 暂无评论