Home > OS >  Wordpress removing <p> tags from WYSIWG custom field on custom post types
Wordpress removing <p> tags from WYSIWG custom field on custom post types

Time:09-28

I'm using Metabox to create a custom post type "services" and some custom fields where I can add content. One field is a "What you see is what you get" field (WYSIWYG) but Wordpress removes the p tags automatically.

I've managed to sort this issue on pages and posts by adding the following to the functions.php file...

remove_filter( 'the_content', 'shortcode_unautop' );

It doesnt seem to work on custom post types so is there a way to do the same for these?

CodePudding user response:

The WordPress plugin called TinyMCE Advanced will solve your problem.

This plugin comes with an option inside Settings > TinyMCE Advanced that will fix your disappearing p tags. Mark the checkbox labeled Stop removing the p when saving and show them in the Text editor and your p tags will be preserved.

For more details please check https://wordpress.stackexchange.com/questions/137968/wordpress-removing-p-tags

CodePudding user response:

Try adding the following to stop auto removal/addition of p tags from all posts/pages/custom post types:

remove_filter (‘the_content’, ‘wpautop’);
remove_filter (‘the_excerpt’, ‘wpautop’);

Or you can use the plugin Toggle wpautop which works fine for custom post types too

  • Related