Back to blog

How to Add CommentBy to WordPress in 2 Minutes

6 min read

How to Add CommentBy to Your WordPress Site (2 Minutes)

I built CommentBy because I got tired of comment systems that track users everywhere. Adding it to WordPress is dead simple - if you can add Google Analytics, you can add CommentBy.

Here's the thing: you don't need a plugin, special configuration, or any WordPress coding knowledge. It's just a script tag and a div. Let me show you.

Before You Start

  1. Sign up at commentby.com - choose your plan (30-day free trial, no credit card required)
  2. Add your WordPress site URL in the CommentBy dashboard
  3. That's it - no API keys, site IDs, or configuration needed

The widget automatically detects your domain and shows the right comments. No manual setup.

The 2-Minute Setup

What you need:

  • A CommentBy account (signed up from step above)
  • Access to your WordPress dashboard

That's it. The script and div are all you need to add.

Three Ways to Add CommentBy

Pick whichever feels safest for your skill level:

  • Option 1 (Easiest): Use WPCode plugin - no theme file editing required
  • Option 2: Edit your theme files directly (comments.php)
  • Option 3: Use WordPress hooks in functions.php (developers)

All three do the exact same thing. Choose based on your comfort level.


Option 1: The "I Don't Want to Edit Theme Files" Method

This is the easiest and safest approach. Use a code snippets plugin instead of editing theme files. This adds BOTH the script and the div in one go.

  1. Install WPCode (free plugin, super popular)
  2. Go to Code Snippets → + Add Snippet
  3. Choose "Add Your Custom Code"
  4. Pick "HTML Snippet"
  5. Paste this (both the script AND the div together):
<script defer src="https://cdn.commentby.com/widget.js"></script>
<div id="commentby_comment_box"></div>
  1. Set "Auto Insert" to "After Post Content"
  2. Set "Location" to "Site Wide" (or select specific post types)
  3. Click Activate

Done. No theme file editing, survives theme updates, works everywhere.

Why this method rocks:

  • Adds both script and div together - nothing to forget
  • Survives theme updates automatically
  • No risk of breaking your site with a typo
  • Can enable/disable with one click
  • Works with any theme

Option 2: Edit Theme Files Directly

If you're comfortable editing theme files (or want full control), this approach works perfectly.

Step 1: Add the CommentBy Script

Add this script tag to your theme's footer.php file, right before the closing </body> tag:

<script defer src="https://cdn.commentby.com/widget.js"></script>

To find footer.php: Go to Appearance → Theme Editor → select footer.php from the right sidebar.

Step 2: Add the Comment Container

Edit comments.php (or single.php), find where WordPress comments normally appear (usually starts with <?php if ( comments_open() ) : ?>), and replace it with:

<?php if ( comments_open() ) : ?>
    <div id="commentby_comment_box"></div>
<?php endif; ?>

Important: If you're editing theme files directly, use a child theme. Otherwise, theme updates will erase your changes.

That's it. The script loads the widget, and the div tells it where to appear.


Option 3: The "I Know PHP" Method

If you want programmatic control, add this to your child theme's functions.php:

// Add CommentBy script to footer
function commentby_add_script() {
    ?>
    <script defer src="https://cdn.commentby.com/widget.js"></script>
    <?php
}
add_action('wp_footer', 'commentby_add_script');

// Add CommentBy widget in comments area
function commentby_add_widget() {
    if (is_single() && comments_open()) {
        echo '<div id="commentby_comment_box"></div>';
    }
}
add_action('comment_form_before', 'commentby_add_widget');

This approach:

  • Only loads on single posts
  • Only shows when comments are enabled for that post
  • Appears in the proper comments section (not inside post content)
  • Survives theme updates (if you use a child theme)

Does It Work Like the HTML Example?

Yes. CommentBy works the exact same way on WordPress as it does on static HTML sites.

The script tag loads the widget code, and the <div id="commentby_comment_box"></div> is where comments appear.

No difference between WordPress, static HTML, Next.js, or anything else. That's the point - simple embed that works everywhere.

Common Questions

Q: Do I need to disable WordPress's native comments?

You can if you want a cleaner setup, but it's not required. If you replace the comment section in comments.php with the CommentBy div, WordPress comments won't show anyway.

To fully disable: Settings → Discussion → uncheck "Allow people to submit comments on new posts"

Q: Will this slow down my site?

No. The script loads with the defer attribute, meaning it doesn't block your page from rendering. CommentBy loads after your content appears, so visitors see your post immediately.

Q: What if I switch themes?

  • Option 1 (WPCode): Keeps working automatically
  • Option 2 (Theme files): You'll need to re-add the code to your new theme
  • Option 3 (functions.php): Keeps working if in child theme

Q: Can I customize the appearance?

Yes - log into your CommentBy dashboard and customize colors, fonts, etc. Changes apply across all your sites automatically. No need to update WordPress.

Q: What about mobile?

Works automatically. CommentBy is responsive by default.

Q: How does CommentBy know which site's comments to show?

CommentBy automatically detects your site based on the domain. Each domain gets its own comment space - no manual configuration needed.

Troubleshooting

Comments not showing up?

  1. Check browser console (F12 → Console tab) for JavaScript errors
  2. Make sure the <div id="commentby_comment_box"></div> exists on the page (right-click → Inspect)
  3. Verify the script is loading from https://cdn.commentby.com/widget.js
  4. Check if you have caching plugins - clear all caches
  5. Try in an incognito window while logged out

Script not loading?

  • Some security plugins block external scripts - whitelist cdn.commentby.com
  • Check if your theme has Content Security Policy headers that block external JS

Still stuck?

Email me - I'm the one who built this, I'll help you get it working.

Why This Works Better Than Disqus

Since I spent way too long researching comment systems before building CommentBy:

Disqus makes you install a plugin, create API applications, sync databases, and deal with 70+ HTTP requests per page. It's overkill.

CommentBy is one script tag and a div.

That's the entire difference. No tracking, no ads, no complicated setup. Just comments.

Final Thoughts

If you can add Google Analytics to WordPress, you can add CommentBy. It's the same level of difficulty - paste a script, paste a div, done.

Pick your path:

  • Beginner? Use Option 1 (WPCode plugin)
  • Comfortable with themes? Use Option 2 (edit comments.php directly)
  • Developer? Use Option 3 (functions.php hooks)

All three work identically. Pick whichever feels safest.

And yeah, it works exactly like the HTML example. That's intentional - I wanted something that doesn't require you to learn a platform-specific API or integration method.

Questions? Issues? Email me. I actually respond.


Ready to try it? Start your free 30-day trial.


Back to blog