WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 0 down vote accepted

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;
share|improve this answer
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? – Ronburgundy Jul 17 '13 at 16:06
Answer updated, check it.Code in answer is test with bbpress.ed_buttons is a object while QTags is function. – Ravinder Kumar Jul 17 '13 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) – Ronburgundy Jul 17 '13 at 21:51
Ive accepted your answer, as it does what i asked, but does not function how I wish it functioned... – Ronburgundy Jul 18 '13 at 2:18
wihthout seeing your test it's difficult to tell what's wrong.do you have live test site? – Ravinder Kumar Jul 18 '13 at 6:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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