我们需要在Wordpress的Html文本编辑器中加入自定义标签按钮,以便于快捷的编辑写文章。
比如 h1 h2 h3等常用标签
找到wp主题的functions.php文件,路径为:/home/wp-content/themes/主题文件夹/functions.php,然后将以下代码添加
//文本编辑器添加自定义代码标签 add_action(‘after_wp_tiny_mce’, ‘add_button_mce’); function add_button_mce($mce_settings) { ?> <script type=”text/javascript”> QTags.addButton( ‘h1’, ‘h1’, “<h1>”, “</h1>” ); QTags.addButton( ‘h2’, ‘h2’, “<h2>”, “</h2>” ); QTags.addButton( ‘h3’, ‘h3’, “<h3>”, “</h3>” ); QTags.addButton( ‘h4’, ‘h4’, “<h4>”, “</h4>” ); QTags.addButton( ‘h5’, ‘h5’, “<h5>”, “</h5>” ); QTags.addButton( ‘pre’, ‘pre’, “<pre>”, “</pre>” ); QTags.addButton( ‘kbd’, ‘kbd’, “<kbd>”, “</kbd>” ); </script> <?php } |