# Bricks Dynamic Tag: {wpide_reading_time}

> Adds a {wpide_reading_time} dynamic data tag that shows the estimated reading time of the current post ("5 min read"), for single templates and query loops.

- Type: PHP
- Runs: Run everywhere
- Category: [Page Builders & Themes](https://wpide.com/library/category/page-builders/)
- Tags: bricks, dynamic-data, reading-time
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bricks-dynamic-tag-reading-time/

## Code

```php
// Average reading speed in words per minute.
$wpide_bricks_wpm = 220;

$wpide_bricks_reading_time = function ( $post_id ) use ( $wpide_bricks_wpm ) {
    $words = str_word_count( wp_strip_all_tags( (string) get_post_field( 'post_content', $post_id ) ) );

    return sprintf( '%d min read', max( 1, (int) ceil( $words / max( 1, $wpide_bricks_wpm ) ) ) );
};

add_filter( 'bricks/dynamic_tags_list', function ( $tags ) {
    $tags[] = array( 'name' => '{wpide_reading_time}', 'label' => 'Reading time', 'group' => 'Post' );

    return $tags;
} );

add_filter( 'bricks/dynamic_data/render_tag', function ( $tag, $post = null, $context = 'text' ) use ( $wpide_bricks_reading_time ) {
    $name = is_string( $tag ) ? trim( $tag, '{}' ) : $tag;

    if ( 'wpide_reading_time' !== $name ) {
        return $tag;
    }

    return $wpide_bricks_reading_time( $post instanceof WP_Post ? $post->ID : get_the_ID() );
}, 20, 3 );

$wpide_bricks_reading_replace = function ( $content, $post = null ) use ( $wpide_bricks_reading_time ) {
    if ( ! is_string( $content ) || false === strpos( $content, '{wpide_reading_time}' ) ) {
        return $content;
    }

    return str_replace( '{wpide_reading_time}', $wpide_bricks_reading_time( $post instanceof WP_Post ? $post->ID : get_the_ID() ), $content );
};

add_filter( 'bricks/dynamic_data/render_content', $wpide_bricks_reading_replace, 20, 2 );
add_filter( 'bricks/frontend/render_data', $wpide_bricks_reading_replace, 20, 2 );
```

## Notes

Change the words-per-minute value to match your audience.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Bricks Dynamic Tag: {wpide_reading_time}" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
