Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'init', function() {
- remove_post_type_support( 'code-snippet', 'excerpt' );
- remove_post_type_support( 'code-snippet', 'editor' );
- } );
- // Now create 2 fields for excerpt and content.
- // I'll show a way to use code and a way to use Builder.
- add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
- $meta_boxes[] = [
- 'title' => 'Code Snippet Before',
- 'post_types' => 'code-snippet',
- 'fields' => [
- [
- 'type' => 'wysiwyg',
- 'id' => 'content', // This is the must!
- 'name' => 'Reason for snippet',
- ],
- [
- 'type' => 'wysiwyg',
- 'id' => 'excerpt', // This is the must!
- 'name' => 'Snippet Excerpt',
- ],
- // Custom style to overwrite the editor style set by WordPress.
- [
- 'type' => 'custom_html',
- 'std' => '<style>#wp-content-editor-tools{background:none;padding-top:0;}</style>',
- ],
- ],
- ];
- return $meta_boxes;
- } );
- // This is for content
- add_filter( 'rwmb_content_field_meta', function() {
- $post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
- return get_post_field( 'post_content', $post_id );
- } );
- add_filter( 'rwmb_content_value', '__return_empty_string' );
- // This is for excerpt only.
- add_filter( 'rwmb_excerpt_field_meta', function() {
- $post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMBER_INT );
- return get_post_field( 'post_excerpt', $post_id );
- } );
- add_filter( 'rwmb_excerpt_value', '__return_empty_string' );
Advertisement
Add Comment
Please, Sign In to add comment