In the members-only forum a user asked:
I know that many bloggers like to do drawings for prizes and use a random number generator. Then they choose the winning number of the commenter for that blog post. My client has her comments numbered like that, but when I changed her blog to Dynamik Genesis, it isn’t working quite right.
Here is a screenshot: http://screencast.com/t/Tc4iZmqA
I found the code I needed at this link: http://www.studiopress.com/forums/topic/numbering-comments-in-decor-child-theme/ which I put in the Dynamik Custom functions file.
If you can’t see this link, the plugin I’m using is http://wordpress.org/extend/plugins/gregs-threaded-comment-numbering/
and the code I put in the Dynamik Custom functions file is:/** Add comment numbering */
add_action( ‘genesis_before_comment’, ‘modernblogger_numbered_comments’ );
function modernblogger_numbered_comments () {
if (function_exists( ‘gtcn_comment_numbering’ ))
echo gtcn_comment_numbering($comment->comment_ID, $args);
}However, the problem is that it numbers the replies to the commnents as well. Since my client doesn’t want her replies to the comments included in the numbering, I’m trying to figure out how to just have the plugin call numbers for the comments.
I hope that makes sense and that you can help me. I know a lot of people are looking for this answer because I found them but there were no answers.
We can change the built-in HTML5 comment callback to that of Greg’s Threaded Comment Numbering plugin to get comment numbering in Genesis.
Dynamik specific changes are mentioned where necessary.
Step 1
Install and activate Greg’s Threaded Comment Numbering plugin.
Step 2
Add the following in child theme’s functions.php:
// Change 'genesis_html5_comment_callback' to 'gtcn_basic_callback' provided by Greg's Threaded Comment Numbering plugin for numbering commnets | |
add_filter( 'genesis_comment_list_args', 'sk_add_numbered_comments' ); | |
function sk_add_numbered_comments( $defaults ) { | |
if ( function_exists( 'gtcn_basic_callback' ) ) { | |
$defaults['callback'] = genesis_html5() ? 'gtcn_basic_callback' : 'genesis_comment_callback'; | |
} | |
return $defaults; | |
} |
If you are using Dynamik, this goes in Genesis > Dynamik Custom > Functions.
Step 3
[Optional] Add the following in child theme’s style.css:
.commentnumber { | |
float: right; | |
font-size: 12px; | |
background: #ddd; | |
padding: 5px 10px; | |
} |
If you are using Dynamik, this goes in Genesis > Dynamik Custom > CSS. You may also additionally add margin-left: 20px;
for .commentnumber
.
References:
genesis/lib/structure/comments.php
I am creating a threaded comment using php. I using this code to display the threaded comments. I can any one tell how to limit the displaying. When threads run multiple pages, it seems that WP starts the numbering over again on each page.