{"id":115,"date":"2014-02-15T11:45:14","date_gmt":"2014-02-15T18:45:14","guid":{"rendered":"http:\/\/laubsterboy.com\/blog\/?p=115"},"modified":"2014-02-15T11:45:14","modified_gmt":"2014-02-15T18:45:14","slug":"wordpress-richtext-editor-for-excerpts","status":"publish","type":"post","link":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/","title":{"rendered":"WordPress Richtext Editor for Excerpts"},"content":{"rendered":"<p>Occasionally when creating a WordPress theme the design relies on using the excerpt meta box, but forcing the end user to manually type html tags defeats the entire purpose of using WordPress (or any CMS for that matter) and adds a layer of unnecessary complexity to editing posts, pages, or any other post type. To make things simpler you can replace the Excerpt meta box with a rich-text editor, just like the main content editor. This can be done by installing an additional plugin, however with just a couple extra lines of code it can also be done through your theme.<\/p>\n<pre class=\"lang:php decode:true crayon-selected\" title=\"Excerpt Editor\">function lb_editor_remove_meta_box() {\n\tglobal $post_type;\n\n\t\/\/ Check to see if the global $post_type variable exists\n\t\/\/ and then check to see if the current post_type supports\n\t\/\/ excerpts. If so, remove the default excerpt meta box\n\t\/\/ provided by the WordPress core. If you would like to only\n\t\/\/ change the excerpt meta box for certain post types replace\n\t\/\/ $post_type with the post_type identifier.\n\tif (isset($post_type) &amp;&amp; post_type_supports($post_type, 'excerpt')) remove_meta_box('postexcerpt', $post_type, 'normal');\n}\nadd_action('admin_menu', 'lb_editor_remove_meta_box');\n\nfunction lb_editor_add_custom_meta_box() {\n\tglobal $post_type;\n\n\t\/\/ Again, check to see if the global $post_type variable\n\t\/\/ exists and then if the current post_type supports excerpts.\n\t\/\/ If so, add the new custom excerpt meta box. If you would\n\t\/\/ like to only change the excerpt meta box for certain post\n\t\/\/ types replace $post_type with the post_type identifier.\n\tif (isset($post_type) &amp;&amp; post_type_supports($post_type, 'excerpt')) add_meta_box('postexcerpt', __('Excerpt'), 'lb_editor_custom_post_excerpt_meta_box', $post_type, 'normal', 'high');\n}\nadd_action( 'add_meta_boxes', 'lb_editor_add_custom_meta_box' );\n\nfunction lb_editor_custom_post_excerpt_meta_box( $post ) {\n\t\/\/ Adjust the settings for the new wp_editor. For all\n\t\/\/ available settings view the wp_editor reference\n\t\/\/ http:\/\/codex.wordpress.org\/Function_Reference\/wp_editor\n\t$settings = array( 'textarea_rows' =&gt; '12', 'quicktags' =&gt; false, 'tinymce' =&gt; true);\n\n\t\/\/ Create the new meta box editor and decode the current\n\t\/\/ post_excerpt value so the TinyMCE editor can display\n\t\/\/ the content as it is styled.\n\twp_editor(html_entity_decode(stripcslashes($post-&gt;post_excerpt)), 'excerpt', $settings);\n\n\t\/\/ The meta box description - adjust as necessary\n\techo '&lt;p&gt;&lt;em&gt;Excerpts are optional, hand-crafted, summaries of your content.&lt;\/em&gt;&lt;\/p&gt;';\n}<\/pre>\n<p>Thats it! The above code can be placed in the functions.php file of your theme or placed in its own plugin file. Note that typically with custom meta boxes additional code must be added to save the meta box value when the post\/page is published or updated, however since the meta box is replacing the excerpt WordPress automatically handles this process.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Occasionally when creating a WordPress theme the design relies on using the excerpt meta box, but forcing the end user to manually type html tags defeats the entire purpose of using WordPress (or any CMS for that matter) and adds a layer of unnecessary complexity to editing posts, pages, or any other post type. To [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3],"tags":[5,26,54,55,64,68],"class_list":["post-115","post","type-post","status-publish","format-standard","hentry","category-guide","tag-add_meta_box","tag-excerpt","tag-remove_meta_box","tag-richtext","tag-wordpress","tag-wp_editor"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WordPress Richtext Editor for Excerpts - John Russell Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WordPress Richtext Editor for Excerpts - John Russell Blog\" \/>\n<meta property=\"og:description\" content=\"Occasionally when creating a WordPress theme the design relies on using the excerpt meta box, but forcing the end user to manually type html tags defeats the entire purpose of using WordPress (or any CMS for that matter) and adds a layer of unnecessary complexity to editing posts, pages, or any other post type. To [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/\" \/>\n<meta property=\"og:site_name\" content=\"John Russell Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-15T18:45:14+00:00\" \/>\n<meta name=\"author\" content=\"John Russell\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@laubsterboy\" \/>\n<meta name=\"twitter:site\" content=\"@laubsterboy\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"John Russell\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/\"},\"author\":{\"name\":\"John Russell\",\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/296c0c6bd1deeeb20834393e1e16325c\"},\"headline\":\"WordPress Richtext Editor for Excerpts\",\"datePublished\":\"2014-02-15T18:45:14+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/\"},\"wordCount\":169,\"commentCount\":3,\"keywords\":[\"add_meta_box\",\"excerpt\",\"remove_meta_box\",\"richtext\",\"WordPress\",\"wp_editor\"],\"articleSection\":[\"Guide\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/\",\"url\":\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/\",\"name\":\"WordPress Richtext Editor for Excerpts - John Russell Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/#website\"},\"datePublished\":\"2014-02-15T18:45:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/296c0c6bd1deeeb20834393e1e16325c\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.johnrussell.dev\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress Richtext Editor for Excerpts\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/#website\",\"url\":\"https:\/\/www.johnrussell.dev\/blog\/\",\"name\":\"John Russell Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.johnrussell.dev\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/296c0c6bd1deeeb20834393e1e16325c\",\"name\":\"John Russell\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/00ce0f258fcc5e5d29897a5e81316009713e9104cfaf49f481c5bce3f81c7cb1?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/00ce0f258fcc5e5d29897a5e81316009713e9104cfaf49f481c5bce3f81c7cb1?s=96&d=mm&r=g\",\"caption\":\"John Russell\"},\"url\":\"https:\/\/www.johnrussell.dev\/blog\/author\/laubsterboy\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WordPress Richtext Editor for Excerpts - John Russell Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/","og_locale":"en_US","og_type":"article","og_title":"WordPress Richtext Editor for Excerpts - John Russell Blog","og_description":"Occasionally when creating a WordPress theme the design relies on using the excerpt meta box, but forcing the end user to manually type html tags defeats the entire purpose of using WordPress (or any CMS for that matter) and adds a layer of unnecessary complexity to editing posts, pages, or any other post type. To [&hellip;]","og_url":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/","og_site_name":"John Russell Blog","article_published_time":"2014-02-15T18:45:14+00:00","author":"John Russell","twitter_card":"summary_large_image","twitter_creator":"@laubsterboy","twitter_site":"@laubsterboy","twitter_misc":{"Written by":"John Russell","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#article","isPartOf":{"@id":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/"},"author":{"name":"John Russell","@id":"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/296c0c6bd1deeeb20834393e1e16325c"},"headline":"WordPress Richtext Editor for Excerpts","datePublished":"2014-02-15T18:45:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/"},"wordCount":169,"commentCount":3,"keywords":["add_meta_box","excerpt","remove_meta_box","richtext","WordPress","wp_editor"],"articleSection":["Guide"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/","url":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/","name":"WordPress Richtext Editor for Excerpts - John Russell Blog","isPartOf":{"@id":"https:\/\/www.johnrussell.dev\/blog\/#website"},"datePublished":"2014-02-15T18:45:14+00:00","author":{"@id":"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/296c0c6bd1deeeb20834393e1e16325c"},"breadcrumb":{"@id":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.johnrussell.dev\/blog\/2014\/02\/wordpress-richtext-editor-for-excerpts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.johnrussell.dev\/blog\/"},{"@type":"ListItem","position":2,"name":"WordPress Richtext Editor for Excerpts"}]},{"@type":"WebSite","@id":"https:\/\/www.johnrussell.dev\/blog\/#website","url":"https:\/\/www.johnrussell.dev\/blog\/","name":"John Russell Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.johnrussell.dev\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/296c0c6bd1deeeb20834393e1e16325c","name":"John Russell","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.johnrussell.dev\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/00ce0f258fcc5e5d29897a5e81316009713e9104cfaf49f481c5bce3f81c7cb1?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/00ce0f258fcc5e5d29897a5e81316009713e9104cfaf49f481c5bce3f81c7cb1?s=96&d=mm&r=g","caption":"John Russell"},"url":"https:\/\/www.johnrussell.dev\/blog\/author\/laubsterboy\/"}]}},"_links":{"self":[{"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/posts\/115","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/comments?post=115"}],"version-history":[{"count":0,"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/posts\/115\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/media?parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/categories?post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.johnrussell.dev\/blog\/wp-json\/wp\/v2\/tags?post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}