Shortcode preview

Example rendered output for a 350-word post.

2 min

Getting started

Use a local WordPress installation. Upload plugin.zip in Plugins → Add New, activate it, and add the shortcode to a test post.

[betavan_reading_time]
Compatibility and review

Use the demo with synthetic inputs and review its behavior in your own tools before adapting it.

Resource files

Inspect the original contents and download individual files.

Download file

<?php
/**
 * Plugin Name: Betavan Reading Time Demo
 * Description: Adds an estimated reading time through the [betavan_reading_time] shortcode.
 * Version: 0.1.0
 * License: MIT
 */
if (!defined("ABSPATH")) { exit; }
add_shortcode("betavan_reading_time", function () {
    $post = get_post();
    if (!$post) { return ""; }
    $content = wp_strip_all_tags(strip_shortcodes($post->post_content));
    $words = preg_split("/\s+/u", trim($content), -1, PREG_SPLIT_NO_EMPTY);
    $minutes = max(1, (int) ceil(count($words ?: []) / 220));
    return esc_html((string) $minutes) . " min";
});