KNOWNHOST WIKI

User Tools

Site Tools


resources:wordpress-comments-formatting

How to Make WordPress Comments Bold?

WordPress comments, by default, allow for certain HTML markup to be included. Bolding the text is an example of default HTML markup that is allowed.

To bold text within a comment, markup your text, starting with <b> and ending with </b>. After you save the comment, the markup will disappear and the change will be implemented.

If the above had been a comment, it would appear as:

  To bold text within a comment, markup your text, starting with and ending with . 
  After you save the comment, the markup will disappear and the change will be implemented.

So, please be sure to take into account the fact that the tags will disappear once you save the changes, with those changes implemented in the text.


How to Center WordPress Comments / Comment Form?

If you’d like the comment form centered on the page, the change is relatively trivial, assuming your theme hasn’t changed the behavior, in which case you’ll have to inspect element on the particular Comments, Comment Form, Respond div (depending on what it’s called in your theme).

Using Customizer, login to the WordPress admin panel and select

  Appearance -> Customize

Then scroll down to Additional CSS.

To center the comment form, insert this code in the box:

  #respond p {
    text-align: center;
  }

Note: If this doesn’t work, then inspect element on a post page comment form to see what CSS you need to set “text-align: center;”.


How to Show WordPress Comment Counts?

There are a couple of different places you might want to display your WordPress comment counts, such as on the actual post page - giving visitors the opportunity to see how popular a post is, without scrolling down a bunch, or showing the comment statistics on the WP admin side of things, where your admin staff can see it, but regular users cannot.


Show Comment Counts on Posts (Public Facing)

One of the more flexible approaches is to create a shortcode to your child theme functions.php and then include that shortcode on your posts wherever you’d like the comment count to appear.

  add_shortcode( 'showcomment_count', 'commentnum' );
  function commentnum() {
    $commentnumber= get_comments_number(get_the_ID());
    return $commentnumber;
  }

Now, wherever you’d like the comment count to appear, just insert [showcomment_count] in your child theme file (such as the post template / theme page).


Show Comment Counts on Admin Pages (Admin Facing)

Instead of showing publicly, perhaps you’d rather have some admin statistics available to summarize the state of your comments, so you instantly know how many you’ve got, and can monitor performance with ease.

You can use a plugin-based approach for adding comment statistics, and other stats, to your WP admin area.

Install the WP Statistics plugin using our How to Install Plugins procedure: 1)WP Statistics

Once you’ve installed and activated the plugin, navigate to the plugin settings and configure to suit.


How to Change WordPress Comment Submit Button Text?

If you’re looking to change the text on the comment submit button, which normally says, “Post Comment”, you’ve got a few options at your disposal.

For example, you could edit your theme file comment.php, though with any upgrades you could easily find that file overwritten and have to perform the changes again.

Or, you could create a child theme, copy that file over and then edit it, so that you preserve the integrity of core files and theme files and eliminate the risk of upgrade overwrites.

There are occasions when you’d like to change something without editing any files. Through the use of a search and replace plugin, you can edit the comment button text and not have to worry about editing files.

Install the CM On Demand Search and Replace plugin using our How to Install Plugins procedure: 2)CM on Demand Search and Replace

Once you’ve installed and activated the plugin, navigate to the plugin settings and configure to suit. Given the myriad of choices available, you might want to consult the plugin developer information pages for details about what you can do exactly: 3)Search and Replace Plugin for Wordpres

However, you’ll find that changing the comment button text takes just a few seconds with this handy plugin.


How to Collapse Long WordPress Comments with Read More?

When there are long comments that stylistically don’t appeal to you, and you’d like to retain those comments, but just massage their display so they’re a bit more palatable, much like how Amazon comments work, consider collapsing the content with a, “Read More” link, that when clicked will open up the remainder of the comment for full reading.

There are a number of similar solutions in the WordPress.org plugin repository, most of which rely on one or another of the jQuery Collapser (or similar jQuery code).

Install the Truncate Comments plugin using our How to Install Plugins procedure: 4)truncate comments

Within the plugin settings page on WP admin, you can choose what the, “Read More” text should be, the speed of the expanding action, what size of comment should trigger the truncate plugin and even whether to use, “…” or something else instead.


How to Style Post Author Comments in WordPress Without a Plugin?

The beauty of Customizer is that you can make big-impact CSS changes with minimal effort, and without changing the coding of your core files or even theme files directly, by going to the WordPress admin panel and selecting:

  Appearance -> Customize

Then scroll down to Additional CSS.

Author comments are comments made by the post author, obviously. However, when you scroll through a list of comments on a post, you’d have no obvious way of knowing that fact. It’s only when you style author comments differently than you do visitor comments, that they begin to stand out.

Author comments can be made colorful, larger, bolder or whatever CSS styling you’d like to apply. One of our favorites is to add background color to the entire area, so that it stands out from the rest, clearly.

To add a background for only author comments, insert this code in the box:

  .commentlist .bypostauthor {background: #cccccc;}
  .commentlist li ul.children li.bypostauthor {background: #cccccc;}

Note: Change the color to whatever works with your theme. If you find this doesn’t work, you may have to inspect element on an author comment and see what CSS classes have been used in place of .commentlist .bypostauthor.


How to Blockquote Text in WordPress Comments?

WordPress comments, by default, will allow some HTML markup tags to be included. Blockquotes in some of the text is default HTML markup that is allowed.

To blockquote text within a comment, markup your text, starting with < blockquote > and ending with </ blockquote >. After you save the comment, the markup will disappear and the change will be implemented.

If the above had been a comment, it would appear as: To blockquote text within a comment, markup your text, starting with " and ending with " . After you save the comment, the markup will disappear and the change will be implemented.

Take into account the fact that the tags will disappear once you save the changes, with those changes implemented in the text.


How to Change WordPress Comments Reply Title “Leave a Reply”?

If you’ve got a comment form appearing on posts and/or pages, but are tired of the core text, “Leave a Reply” and would like to tweak that test to read differently, there are a few basic approaches from which to choose.


In your core WordPress files, you’ll notice comments.php. You can edit this file directly, searching for the text, Leave a Reply, changing it to whatever you want and then saving.

The only problem with this approach is that whenever you get a core update that overwrites this file, you’ll lose your changes and have to do them all over again.


In your core WordPress files, you’ll notice functions.php. You can edit this file directly, inserting this small bit of tweaked code, then saving.

  function replytitle_mod ($mytitle) {
    $mytitle['title_reply'] = __('Your Updated Title Text:');return $mytitle;
  }
  add_filter('comment_form_defaults','replytitle_mod');

The only problem with this approach is that whenever you get a theme update that overwrites this file, you’ll lose your changes and have to do them all over again.


Create a Child Theme and Then Edit the functions.php File

The right way of approaching this would be to create a child theme, copy over the parent functions.php to the child theme and edit it within the child theme. That way, parent theme updates won’t break the functionality and the child theme function will continue to exist, even when there are theme updates.

Just add this to your functions.php:

  function replytitle_mod ($mytitle) {
    $mytitle['title_reply'] = __('Your Updated Title Text:');
    return $mytitle;
  }
  add_filter('comment_form_defaults','replytitle_mod');
resources/wordpress-comments-formatting.txt · Last modified: 2020/06/01 08:14 by Karson N.