I am pulling info from the excerpt of a custom post type into a 3rd party application. I need to be able to add line breaks and for them to be saved in the database. If my user switches to "visual" from "text" and saves the post, the
tags are stripped out.

My solution was to disable the use of the rich text editor for my custom post type. Solution was from user @biziclop here; Is it possible to remove WYSIWYG for a certain Custom Post Type?

add_filter('user_can_richedit', 'disable_wyswyg_for_custom_post_type');
function disable_wyswyg_for_custom_post_type( $default ){
  if( get_post_type() === 'custom-post-type') return false;
  return $default;

I need to leave the WYSIWYG tools for the main post content. Reading the codex, there are no parameters for the user_can_richedit function: https://codex.wordpress.org/Function_Reference/user_can_richedit

Is there a way to modify my filter to only target the excerpt?

Thank you in advance!

1 Answer 1


Excerpts can be automatically generated in which case you have some control over them or manually generated in which case there is very little control available, and the wordpress way is that they may have any type of content. if you need something more restrictive you will need to create your own "meta box" for your specific needs, and probably design an API to retrieve it.

The other alternative is to not use an excerpt retrieved using the wordpress APIs but generate one by yourself from the content.

  • Thanks for the suggestion, I actually did already build an API to import the 20+ custom fields I created. Might as well make my own meta box as you suggest. It's a little more work, but probably a more solid solution than disabling the WYSIWYG.
    – Jason
    Apr 17, 2018 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.