BlogThemes

How to Add Numbers to Your WordPress Comments Layout

Earlier on WPBeginner, we confirmed you  type your WordPress feedback and the comment form. On this article, we’ll present you additional customise the remark format by including numbers to your WordPress feedback.

Last outcomes:

Comments with numbers in WordPress

Including Remark Numbering in WordPress

Very first thing it’s good to do is set up and activate Greg’s Threaded Remark numbering plugin. After activating the plugin, go to Settings » Threaded Remark Numbering. Below the Styling Remark Numbers part, choose the choice: No – I’ll present my very own quantity styling. Under that there’s one other choice to Strip the Remark Quantity Wrapper. Choose No on that choice as nicely and save settings.

Configuring threaded comment numbering plugin

Since we aren’t utilizing the plugin’s stylesheet, we have to outline types in our personal stylesheet. We additionally configured the plugin to wrap remark numbers in a <div class="commentnumber"&> wrapper, so we are able to type the quantity utilizing the .commentnumber class. So as to add customized types, go to Look » Editorand add the next code on the backside of your theme’s type.css file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
.commentlist li .commentnumber {
float:proper;
colour:#999999;
font-size:3em;
margin:0;
padding:0 .5em .5em 0;
clear:proper;
}
.commentlist li li .commentnumber {
font-size:1.7em;
}
.commentlist li li li .commentnumber {
font-size:1.3 em;
}

The plugin we’re utilizing makes use of a callback inside wp_list_comments()operate. You may simply edit your theme’s feedback.php template and exchange the prevailing wp_list_comments with the one supplied by the plugin:

1
<?php wp_list_comments('callback=gtcn_basic_callback'); ?>

For most people this could work. Nevertheless for a few of you it could find yourself wanting messy at first. You would want to take a couple of further steps to repair that. Begin out by discovering which callback operate your theme is utilizing for the feedback, after which add the plugin’s callback inside that operate.

To seek out out which operate your theme is utilizing as callback, all it’s important to do is search for wp_list_comments operate in feedback.php template. For instance, within the default WordPress TwentyTwelve theme you’ll see this:

1
<?php wp_list_comments( array( 'callback' => 'twentytwelve_comment', 'type' => 'ol' ) ); ?>

twentytwelve_comment is the callback operate you had been in search of. Now it’s good to go to your theme’s features.php file and search for the remark callback operate. As soon as you discover it, you will want to change this operate and add threaded remark numbering to it simply earlier than the writer identify.

1
2
3
4
<?php
$comment_number = gtcn_comment_numbering($remark->comment_ID, $args);
echo $comment_number;
?>

Save your adjustments and examine your feedback. Your feedback ought to now have numbers on the correct, like this:

Comments with numbers in WordPress

We hope this text helped you add numbers to your WordPress feedback format.

Download The WPSaviour App Now

Related posts
Beginner’s GuideBest WordPress PluginsBlog

9 Best Social Proof Plugins for WordPress & WooCommerce (2020)

Tips

How To Disable The WordPress User Admin Toolbar

Tips

WordPress Front Page vs Homepage

Tips

5 Things You Must Avoid Doing in WordPress

Leave a Reply

Your email address will not be published.

Pay in your preferred currency
Indian rupee
Euro