I am developing a theme and using jquery prettify to style code tags. Sofar I love prettify, and for the most part wordpress is cooperating.

When text is wrapped in <code> tags everything works dandy. But on certain editors, and the bbpress topic / reply / edit , editor the code is wrapped in the the little dash marks just like on these forums, and sometimes the code gets all mangled.

What I am looking to do is force every editor on my wordpress install , or atleast the code buttons on the editor to wrap code in tags instead of the little dash marks. I have looked at some filters but sofar i do not see how to change the output or behavior of the tiny mce fancy editor buttons thats standard with wordpress.

Thanks for any direction or suggestions.

1 Answer 1


put this code in functions.php

function ravs_codeTag_fix(){
    if ( bbp_use_wp_editor() ) :
        jQuery(document).ready( function() {

            /* Use <code> instead of backticks for the Code button in the editor */
            if ( typeof( edButtons ) !== 'undefined' ) {
                edButtons[110] = new QTags.TagButton( 'code', 'code', '<code>', '</code>', 'c' );


bbpress plugin overwrites the code button behaviour ( of wordpress editor ) by putting some script in head.You can find this script in bbpress->templates->default->bbpress-functions.php online 219


1).If you want to customize wordpress editor then you can explore it by going throw WordPress QuickTags API (quicktags.js) and Tinymce WordPress codex.These documention also have good tutorial link which guide you practically.

2).You can use WordPress Plugin AddQuicktag for editing WordPress Editor.This plugin make it easy, Quicktags add to the html - and visual-editor.. It is possible to ex- and import your Quicktags.


paste below code in functions.php.

add_filter( 'bbp_new_topic_pre_content',  'ravs_bbp_code_trick', 10);
add_filter( 'bbp_new_reply_pre_content',  'ravs_bbp_code_trick', 10);
add_filter( 'bbp_new_forum_pre_content',  'ravs_bbp_code_trick', 10);
add_filter( 'bbp_edit_topic_pre_content',  'ravs_bbp_code_trick', 10);
add_filter( 'bbp_edit_topic_pre_content',  'ravs_bbp_code_trick', 10);
add_filter( 'bbp_edit_forum_pre_content',  'ravs_bbp_code_trick', 10);
function ravs_bbp_code_trick( $content ){
    $content = preg_replace( '/\`/','backtick_place', $content );
    $content = preg_replace( $pattrens,'`', $content );
    return $content;
function ravs_bbp_prevent_trick($content){
    $content = preg_replace( '/backtick_place/','`', $content );
    return $content;
  • excellent, I will implement this and accept the answer if it works when I get a chance. If possible could you describe the ed buttons[] array and the QTags.TagButton() functon briefly so I can attempt to implement my own solutions in the future?
    – Vigs
    Jul 17, 2013 at 16:06
  • Answer updated, check it.Code in answer is test with bbpress.ed_buttons is a object while QTags is function. Jul 17, 2013 at 17:13
  • The function now correctly changes the output of the code button to be <code> but now wordpress, or bbpress more so does not display the information correctly. When using backticks the code is displayed fine, but when using <code> bbpress seems to inject closing tags in wierd places breaking it all up, or it just not preserve the code and outputs it as if it were html (testing with html code)
    – Vigs
    Jul 17, 2013 at 21:51
  • Ive accepted your answer, as it does what i asked, but does not function how I wish it functioned...
    – Vigs
    Jul 18, 2013 at 2:18
  • wihthout seeing your test it's difficult to tell what's wrong.do you have live test site? Jul 18, 2013 at 6:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.