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

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?

2 answers

  • answered 2021-09-27 10:22 Maulik Paddharia

    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

  • answered 2021-09-27 10:28 Mustafa sabir

    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

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum