admin管理员组

文章数量:1434929

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

本文标签: theme developmentWpautop in wpeditor not working