{"id":54451,"date":"2017-08-28T19:16:14","date_gmt":"2017-08-28T22:16:14","guid":{"rendered":"https:\/\/wiki.samuelchopard.ch\/?p=54451"},"modified":"2019-03-18T14:29:20","modified_gmt":"2019-03-18T13:29:20","slug":"add-a-button-to-the-wp-html-editor","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/add-a-button-to-the-wp-html-editor\/","title":{"rendered":"Add a button to the WP HTML editor"},"content":{"rendered":"<p><!--more--><\/p>\n<p>This is very useful if you need to add a button that adds some HTML in your page\/post.<\/p>\n<p>To add such a button, paste the following code in your theme&#8217;s <em>functions.php<\/em>:<\/p>\n<pre class=\"EnlighterJSRAW\">\/\/ add more buttons to the html editor\nfunction appthemes_add_quicktags() {\n    if (wp_script_is('quicktags')){\n?&gt;\n    &lt;script type=\"text\/javascript\"&gt;\n    QTags.addButton( 'eg_paragraph', 'BUTTON TITLE', 'CODE OR TEXT TO BE ADDED', '', '', 'BUTTON ALT', 9 ); \/\/ 9 refers to the position of the button in the editor.\n    &lt;\/script&gt;\n&lt;?php\n    }\n}\nadd_action( 'admin_print_footer_scripts', 'appthemes_add_quicktags' );<\/pre>\n<p>&nbsp;<\/p>\n<p>Source:\u00a0<a target=\"_blank\" href=\"https:\/\/codex.wordpress.org\/Quicktags_API\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/codex.wordpress.org\/Quicktags_API<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"This is very useful if you need to add a button that adds some HTML in your page\/post. To add [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,3,9],"tags":[49,93,134,135,205,222],"class_list":["post-54451","post","type-post","status-publish","format-standard","hentry","category-dashboard","category-php-tricks","category-wordpress","tag-button","tag-editor","tag-html","tag-html-editor","tag-page","tag-post"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=54451"}],"version-history":[{"count":1,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54451\/revisions"}],"predecessor-version":[{"id":54863,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54451\/revisions\/54863"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}