Add emoji reactions to a WordPress site

WordPress posts can show live emoji reactions without installing a plugin: the loader goes in through a wp_head hook in your child theme, a floating bar goes in single.php, and each post in the Loop gets an inline bar keyed to get_permalink(). Nothing is stored in your WordPress database, and there's no cookie banner to add.

Before you start

You need a Tapbar: the reactions, the look, and a publishable key (pk_live_…). Sign up, create a Tapbar with your site as an allowed site (add http://localhost:* too, to try it on a dev server), and open its Embed panel — the loader tag there already carries your key. Your AI agent can do this part for you; see the last section.

Add the loader once

The loader goes in a wp_head hook in the child theme's functions.php (update-safe), or a small plugin. It defines the <tapback-bar> element and starts every bar on the page, however many there are:

add_action( 'wp_head', function () { ?>
  <script type="module" async src="https://api.tapback.party/loader.js"
    data-key="pk_live_…" data-api="https://api.tapback.party"></script>
<?php } );

Swap pk_live_… for your own key, or paste the tag from the Embed panel as it is.

Put a floating bar on each post

In single.php, add one bar with layout="float", keyed to the same get_permalink(). It docks in the bottom corner wherever it sits in the markup, and it connects live, so readers see each other's reactions fall.

<?php // single.php — inside The Loop
while ( have_posts() ) : the_post(); the_content(); ?>
  <tapback-bar entity="<?php echo esc_attr( get_permalink() ); ?>" layout="float"></tapback-bar>
<?php endwhile; ?>

Add an inline bar to each post in the list

In the Loop in home.php / index.php, give every post its own bar, keyed to get_permalink(), escaped with esc_attr:

<?php // home.php / index.php — inside The Loop
while ( have_posts() ) : the_post(); ?>
  <article>
    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    <?php the_excerpt(); ?>
    <tapback-bar entity="<?php echo esc_attr( get_permalink() ); ?>" layout="inline" live="off"></tapback-bar>
  </article>
<?php endwhile; ?>

entity names the counter. On a list page it has to be set by hand: a bar without it infers the list page's own URL, so every blurb would share one tally. Emit the same value the post page uses and a reaction on the blurb lands on the same count as one on the post.

live="off" shows each blurb's count without opening a live socket for it; the falling reactions stay on the post page. Bars that load together share one session request (up to 50 bars each), so a reader can reload a 50-post index about ten times a minute; past a few hundred bars on one page, paginate — see Troubleshooting.

Different reactions per post (Plus)

By default every post shows your Tapbar's reactions. On Plus, a post can carry its own: add a named set in the console's Reactions card (say spooky, with a ghost and a skull), then point the post's bar at it.

<?php // single.php — inside The Loop
$tapback_set = get_post_meta( get_the_ID(), 'tapback_set', true ); ?>
<tapback-bar entity="<?php echo esc_attr( get_permalink() ); ?>" layout="float"<?php if ( $tapback_set ) : ?> set="<?php echo esc_attr( $tapback_set ); ?>"<?php endif; ?>></tapback-bar>

Add a custom field named tapback_set with the value spooky to the post. The block editor hides the Custom Fields panel by default; turn it on under Preferences → Panels. Posts without the field get the default bar. To list reactions on the bar instead of naming a set, use reactions="ghost,skull"; the keys have to be on the Tapbar or in its palette.

The list-page bars need no set. A live="off" bar that declares nothing never decides a post's reactions, so the post page's attribute decides them however readers arrive. The attribute applies the first time anyone loads the post; to change a post that's already live, use the ☰ picker in the console's Pages tab or the set_entity_reactions MCP tool. Changing reactions on live pages has the full rules.

To choose a post's reactions by looking at the draft instead, add the in-page picker to the draft render: add the editor <script> and <tapback-editor> to single.php behind an is_preview() check, so the picker only shows up on preview renders. A draft's preview has no pretty permalink yet (get_permalink() returns /?p=123), so the picker would pin the wrong page. Add the tapback_entity() helper from the WordPress install guide to functions.php and use it for the post bar's entity in single.php: it returns the URL the post will have once published, and get_permalink() once it is. It assumes the slug, publish date and permalink structure stay the same between picking and publishing. A draft with no date is treated as dated today, so with a date in the permalink, set the date under Publish → Date before you pick. If anything changes, the reactions you picked stay on the old URL: pick again from the console's Pages tab after publishing.

// functions.php — the post's published URL, even while it's a draft
function tapback_entity( $post = null ) {
  global $wpdb;
  $post = get_post( $post );
  if ( in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft', 'future' ), true ) ) {
    if ( ! function_exists( 'get_sample_permalink' ) ) require_once ABSPATH . 'wp-admin/includes/post.php';
    // a preview reports the draft's date as "now"; a custom publish date lives in the row
    $row = $wpdb->get_row( $wpdb->prepare( "SELECT post_date, post_date_gmt FROM $wpdb->posts WHERE ID = %d", $post->ID ) );
    $clone = clone $post;
    $clone->post_date = ( $row && '0000-00-00 00:00:00' !== $row->post_date_gmt ) ? $row->post_date : current_time( 'mysql' );
    list( $tpl, $name ) = get_sample_permalink( $clone );
    return str_replace( array( '%postname%', '%pagename%' ), $name, $tpl );
  }
  return get_permalink( $post );
}

Check it works

  1. Deploy to a site on the Tapbar's allowed list (or run your dev server, with http://localhost:* allowed). The bar only runs on allowed sites.
  2. Open a post, tap a reaction, and reload. The count is still there.
  3. Open the post list. That post's blurb shows the same count.

If no bar appears, check that the loader tag is in that page's <head> and that the page's origin is allowed — www and the bare domain are separate entries. Troubleshooting maps each symptom to its fix.

Notes for WordPress

Let your agent do it

Connect your agent to the Tapback MCP server — in Claude Code, claude mcp add --transport http tapback https://api.tapback.party/mcp; in Claude Desktop or claude.ai, Add custom connector with https://api.tapback.party/mcp — then paste this prompt:

Add Tapback live reactions to my WordPress site.

1. Connect to the Tapback MCP server at https://api.tapback.party/mcp and let me approve the sign-in.
2. Ask me for my site's domain, then create a Tapbar with that domain as its allowed site. Give it a heart, a star, and a smile to start — I can change these later.
3. Show me the embed snippet and tell me exactly where it goes in WordPress: the loader `<script>` in a `wp_head` hook in the child theme's `functions.php` (update-safe), or a small plugin; an inline bar (`layout="inline"`, `live="off"`) in the Loop in `home.php` / `index.php`, keyed to `get_permalink()`, escaped with `esc_attr`; and a floating bar (`layout="float"`) in `single.php`, keyed to the same `get_permalink()`. The WordPress guide is at https://docs.tapback.party/install/wordpress/ (as markdown: https://docs.tapback.party/install/wordpress/index.md).
4. Once I've deployed, post a test reaction and read the count back so we know it's working.

Set up with your agent has the same prompt for every stack, with an optional step for the in-page picker. Manage from your agent lists everything the agent can reach.