October 18th in Wordpress by .

How to insert HTML/BBcode tags to WordPress Comments Form

I have seen many people asking me how to integrate a simple javascript based editor to wordpress comments form to markup html or bbcode tags. Here is how you do it and its simple.

I will be working on the prototype of this free markup editor and i will be tweaking a bit to make it very  simple and later i will be integrating to wordpress comments form.   It will insert bbcode or html tags to selected text to wordpress comments form.

Here is how the editor will look like upon integrating to wordpress comments form. Please bear with me that i am keeping it very simple specific to main coding. Later you can play around with styling and colors for buttons.

Step 1:

Go to comments.php  which can be found in your theme folder wp-content > themes > yourtheme > comments.php and on the bottom locate this line and remove it.  I am assuming that the current theme is twentyten which is wordpress default theme.

<?php comment_form(); ?>

Replace above line with below code


<h3 id="respond">Leave a Reply</h3>
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
 <p>
 <input name="author" id="author" value="" size="22" tabindex="1" type="text">
 <label for="author">
 <small>Name (required)</small>
 </label>
 </p>
 <p>
 <input name="email" id="email" value="" size="22" tabindex="2" type="text">
 <label for="email">
 <small>Mail (will not be published) required)</small>
 </label>
 </p>
 <p>
 <input name="url" id="url" value="" size="22" tabindex="3" type="text">
 <label for="url">
 <small>Website</small>
 </label>
 </p>
 <p>
 <small><strong>Tags Allowed:</strong>    <?php echo allowed_tags(); ?>  </small>
 </p>
 <p> <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/bbeditor/styles.css" />
 <script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/bbeditor/ed.js"></script>

 <script>edToolbar('comment'); </script>
 <textarea name="comment" id="comment" cols="100" rows="10" tabindex="4">       </textarea>
 </p>
 <p>
 <input name="submit" id="submit" tabindex="5" value="Submit Comment" type="submit">
 <input name="comment_post_ID" value="<?php echo $id; ?>" type="hidden" >
 <?php do_action('comment_form', $post->ID); ?>
 </p>
</form>

As you notice from the above code, all you need is just 3 lines to initiate the javascript editor. It should be above textarea.

<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/bbeditor/styles.css" />
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/bbeditor/ed.js"></script>
<script>edToolbar('comment'); </script>

I will just be using input buttons and wont be using any images to implement this editor. If need be i can specify css code in styles.css to customize the button look.

Step 2:

(i) Create a new folder in your theme, lets say beditor and .

(ii) Depending on whether to insert bbcode or html, download the zip file.

To insert bbcode tags, download this zip file
To insert html tags, download this zip file

You will see 2 files  and some images in the zip file.  Just place just the ed.js and style.css in your newly created beditor folder. Nothing else needed for the editor to work.

Note: If you want bbcode to be parsed by wordpress, you will need to  use this wordpress bbcode plugin without it your bbcodes wont work.

If you have not used css or removed the styles.css file, the editor will look with just buttons.

P.S: I am keeping it very simple and i will just be focusing on the core wordpress integration and later you can play around with css, colors and backgrounds of buttons.

Similar Posts:

35 Comments

  • Heather Green
    October 24, 2010
  • bodrum oteller
    October 26, 2010
  • dont accept
    November 1, 2010
  • dont touch me there
    November 1, 2010
  • Mario Lark
    November 4, 2010
  • m1crosoft
    November 6, 2010
  • PTEC
    November 23, 2010
  • Charolette Lopera
    November 30, 2010
  • Republic Polytechnic
    December 2, 2010
  • See Skornik
    December 2, 2010
  • airless paint sprayer
    December 8, 2010
  • HOw to get rid of moles
    December 11, 2010
  • Jacqualine Flitsch
    December 12, 2010
    • pbu
      December 12, 2010
      • Anna
        February 3, 2011
  • Sammie Gerty
    January 14, 2011
  • Toyota Aristo
    January 31, 2011
  • Gareth
    February 5, 2011
  • keylogger
    February 21, 2011
  • Tim@apply for a loan
    April 19, 2011
  • microsoft ebook
    April 28, 2011
  • Lorenza Daloisio
    May 4, 2011
  • Cannon Goodnight
    May 22, 2011
  • Life Finance
    June 21, 2011
  • wii Remote Controller
    June 22, 2011
  • Malcolm Delio
    June 23, 2011
  • Thái Nguyên
    June 27, 2011
  • David Burrows
    August 12, 2011
  • causes acid reflux
    September 15, 2011
    • pbu
      September 15, 2011
  • John Anderson
    November 4, 2011
  • mole remover
    January 23, 2012
  • Yuri
    April 11, 2012
  • Yuri
    April 11, 2012

Leave A Comment.





Please wrap all source codes with [code][/code] tags. Powered by