Title: Gutenberg Query Loop
Last modified: April 18, 2023

---

# Gutenberg Query Loop

 *  Resolved [JJCoding](https://wordpress.org/support/users/janjacobs/)
 * (@janjacobs)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/gutenberg-query-loop/)
 * Hi,
 * Is there any chance of adding support for adding the shortcode to a default Gutenberg
   Query Loop? Right now it seems to only get the reading time for 1 article (probably
   the first) and then repeats this for every post in the loop instead of calculating
   it again for every item in the loop.
 * Kind regards

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [JJCoding](https://wordpress.org/support/users/janjacobs/)
 * (@janjacobs)
 * [3 years, 1 month ago](https://wordpress.org/support/topic/gutenberg-query-loop/#post-16671923)
 * Fixed this by creating my own filter instead of using a plug-in.
 *     ```wp-block-code
       add_filter( 'render_block', function( $block_content, $block ) {
           if (!is_admin() && ! empty( $block['attrs']['className'] ) && 'reading-time' === $block['attrs']['className']){
                   $post = get_post();
                   $content = $post->post_content;
                   $wpm = 250; // How many words per minute.
                   $clean_content = strip_shortcodes( $content );
                   $clean_content = strip_tags( $clean_content );
                   $word_count = str_word_count( $clean_content );
                   $time = $word_count / $wpm;
   
             		if($time > 1) {
                     $suffix = 'minutes';
                   } else {
                     $suffix = 'minute';
                   }
   
             		if($time < 1) {
                   	$time = '< 1';
                   } else {
                  		$time = ceil( $word_count / $wpm );
                   }
   
                   $block_content = '<span class="read-time">Reading time: ' . $time .' '. $suffix . '</span>';
           }
   
           return $block_content;
       }, 10, 2 );
       ```
   
 * Credit to: [https://generatepress.com/forums/topic/add-reading-time-on-posts-after-the-author-name/](https://generatepress.com/forums/topic/add-reading-time-on-posts-after-the-author-name/)
    -  This reply was modified 3 years, 1 month ago by [JJCoding](https://wordpress.org/support/users/janjacobs/).
 *  [KeanuTang](https://wordpress.org/support/users/tedtang/)
 * (@tedtang)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/gutenberg-query-loop/#post-16945528)
 * I ran into this issue as well. I slapped together this plugin to address it. 
   You just need the build folder and query-loop-shortcode.php:
 * [KeanuTang/query-loop-shortcode: WordPress Plugin for Gutenberg Shortcode Block to Work Within Query Loops (github.com)](https://github.com/KeanuTang/query-loop-shortcode)
 *  Plugin Author [Jason Yingling](https://wordpress.org/support/users/yingling017/)
 * (@yingling017)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/gutenberg-query-loop/#post-17112177)
 * Thanks for sharing. I’ll take a look at options for implementing to be able to
   get the post ID from within a query loop when embedding the shortcode in the 
   post template.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Gutenberg Query Loop’ is closed to new replies.

 * ![](https://ps.w.org/reading-time-wp/assets/icon-256x256.png?rev=2355751)
 * [Reading Time WP](https://wordpress.org/plugins/reading-time-wp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/reading-time-wp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/reading-time-wp/)
 * [Active Topics](https://wordpress.org/support/plugin/reading-time-wp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/reading-time-wp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/reading-time-wp/reviews/)

## Tags

 * [gutenberg](https://wordpress.org/support/topic-tag/gutenberg/)
 * [query loop](https://wordpress.org/support/topic-tag/query-loop/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 3 replies
 * 3 participants
 * Last reply from: [Jason Yingling](https://wordpress.org/support/users/yingling017/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/gutenberg-query-loop/#post-17112177)
 * Status: resolved