How To Make WordPress Comment Quoting FunctionJanuary 12th, 2009 by James | This article was viewed 29,601 times.
What is a Comment Quoting Function?
A picture tells a thousand words.
So basically quoting is used to indicate that you are replying to the person’s statement you have quoted. Thus allowing readers to understand who you are replying to and what your comment is all about.
Building your own WordPress Comment Quoting Function in your Template
I’ve written this in such a way that there is no need to reinstall the plugin and all the tedious stuff when you upgrade your wordpress. All you need to do is,
- Do this one-time implementation and when you upgrade your wordpress …
- Upload your theme
- Activate your theme. And you’re good to go.
PseudoCode of the Function
PseudoCode is a way of describing the flow of the program (in this case, function).
- Get comment ID
- Get data (Name, Date, Quote and Comments) from the comment ID
- Process and separate all the elements stated above
- Process the Comments by deleting <blockquotes> and <br />. So only 1 level quoting is allowed.
- Put all the quotes into a string
- Display the quoted text with Name, Date and Comment in the Comment textarea.
Step By Step Implementation
- Create a “js” folder under your theme section (same level as your .CSS file).
- In the “js” folder, create a .js file for the comment function you are going to create. eg. “post-comment.js” or anything relevant.
- Download/Copy the code I have provided into the .js file you’ve just created in step 2.
- In the <li></li> tag of comment.php (The formula for the function to work)
<?php echo get_avatar( $comment, 40 ); ?>
<cite class=”comment_name”><?php comment_author_link() ?></cite> Says:
<?php if ($comment->comment_approved == ’0′) : ?>
<em>Your comment is awaiting moderation.</em>
<?php endif; ?>
<small class=”commentmetadata”><a href=”#comment-<?php comment_ID() ?>” title=”" class=”comment_date”><?php comment_date(‘F jS, Y’) ?> at <?php comment_time() ?></a> <?php edit_comment_link(‘edit’,' ’,”); ?></small>
<div class=”comment_data”><?php comment_text() ?></div>
- Style your <blockquote> and Quote Button to look pretty in respect to your theme.
13 Responses to “How To Make WordPress Comment Quoting Function”
Leave a Reply
You must be logged in to post a comment.