admin管理员组文章数量:1323330
I dont want to use the WYSIWYG at the top of my Custom Post Type. I want to use a custom field textarea that i can place at bottom of my list of custom fields instead.
Is this possible?
I dont want to use the WYSIWYG at the top of my Custom Post Type. I want to use a custom field textarea that i can place at bottom of my list of custom fields instead.
Is this possible?
Share Improve this question asked Nov 16, 2012 at 16:03 scottgemmellscottgemmell 3451 gold badge2 silver badges6 bronze badges6 Answers
Reset to default 28add_action('init', 'init_remove_support',100);
function init_remove_support(){
$post_type = 'your post type';
remove_post_type_support( $post_type, 'editor');
}
place it to your themes functions.php
You can actually disable the WYSIWYG editor, leaving only the html source editor. Choose a function below:
// disable wyswyg for custom post type, using the global $post
add_filter('user_can_richedit', function( $default ){
global $post;
if( $post->post_type === 'product') return false;
return $default;
});
// disable wyswyg for custom post type, using get_post_type() function
add_filter('user_can_richedit', function( $default ){
if( get_post_type() === 'product') return false;
return $default;
});
Alternatively, you can handle post-editor support directly in your register_post_type()
call, via the 'supports'
parameter in the $args
array.
The default value is: 'supports' => array( 'title', 'editor' )
.
You can change it to whatever you need; for example: 'supports' => array( 'title' )
.
Re: this comment:
I am using Custom Types UI in combo with AdvancedCustomFields.
The Custom Post Types UI Plugin exposes all of the register_post_type()
$args
array parameters in its UI.
In this case, you simply need to find the Supports section, and disable/uncheck Editor:
I will try to do a more complete answer :
If you want to remove all the content editor
The @Oleg Butuzov answer is good :
add_action('init', 'init_remove_support',100);
function init_remove_support(){
$post_type = 'your post type';
remove_post_type_support( $post_type, 'editor');
}
If you want only disable tinymce but let html toolbars
The @biziclop answer is good :
add_filter('user_can_richedit', function( $default ){
global $post;
if( $post->post_type === 'product') return false;
return $default;
});
In this case wp-content-editor-tools
is already visible because expand-editor.js insert toolbars.
If you want to replace the tinymce editor by a simple textarea
I found the answer here.
function wpse_199918_wp_editor_settings( $settings, $editor_id ) {
if ( $editor_id === 'content' && get_current_screen()->post_type === 'custom_post_type' ) {
$settings['tinymce'] = false;
$settings['quicktags'] = false;
$settings['media_buttons'] = false;
}
return $settings;
}
add_filter( 'wp_editor_settings', 'wpse_199918_wp_editor_settings', 10, 2 );
Another, more consistent way to disable the WYSIWYG editor, leaving only the html source editor - is to disallow tinymce using "wp_editor_settings" filter for your custom post type.
function my_post_type_editor_settings( $settings ) {
global $post_type;
if ( $post_type == 'my_post_type' ) {
$settings[ 'tinymce' ] = false;
}
return $settings;
}
add_filter( 'wp_editor_settings', 'my_post_type_editor_settings' );
本文标签: Is it possible to remove WYSIWYG for a certain Custom Post Type
版权声明:本文标题:Is it possible to remove WYSIWYG for a certain Custom Post Type? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742138637a2422483.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论