Title: Query Loop Posts in Gutenberg
Last modified: March 2, 2024

---

# Query Loop Posts in Gutenberg

 *  [Gin](https://wordpress.org/support/users/rawdolphe/)
 * (@rawdolphe)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/query-loop-posts-in-gutenberg/)
 * I am trying to make this plugin work with the Gutenberg Query Loop Block; when
   I click (select or unselect) on the icon it applies to ALL posts in the Query
   Loop.
 * Can anyone help please?
 * I use Gutenberg 2024, and I insert the shortcode [favorite_button] in the post?
 * Is there anything else I should do?
 * Thank you

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

 *  [thatwebsiteisme](https://wordpress.org/support/users/thatwebsiteisme/)
 * (@thatwebsiteisme)
 * [2 years ago](https://wordpress.org/support/topic/query-loop-posts-in-gutenberg/#post-17758832)
 * Might be a bit late to the party but this is what I got to make it work:
 *     ```wp-block-code
       function fav_plugin_id_render($block_content, $block)
       {
           if ($block['blockName'] === 'core/shortcode') {
               $block_content = str_replace("{{post_id}}", get_the_ID(), $block_content);
           }
           return $block_content;
       }
       add_filter('render_block', 'fav_plugin_id_render', 10, 2);
       ```
   
 * And so my shortcodes in the Query Loops become:
 *     ```wp-block-code
       [favorite_button post_id="{{post_id}}"]
       ```
   
 * Found the idea from: [https://wordpress.stackexchange.com/questions/417823/get-the-id-retrieves-same-id-on-gutenbergs-query-loop](https://wordpress.stackexchange.com/questions/417823/get-the-id-retrieves-same-id-on-gutenbergs-query-loop)
 *  Thread Starter [Gin](https://wordpress.org/support/users/rawdolphe/)
 * (@rawdolphe)
 * [2 years ago](https://wordpress.org/support/topic/query-loop-posts-in-gutenberg/#post-17761212)
 * Thanks a lot [@thatwebsiteisme](https://wordpress.org/support/users/thatwebsiteisme/)
   will look into it asap 🙂
 * PS: it’s never too late for a good deed 😛

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

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

 * ![](https://ps.w.org/favorites/assets/icon-128x128.png?rev=1677726)
 * [Favorites](https://wordpress.org/plugins/favorites/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/favorites/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/favorites/)
 * [Active Topics](https://wordpress.org/support/plugin/favorites/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/favorites/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/favorites/reviews/)

## Tags

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

 * 3 replies
 * 2 participants
 * Last reply from: [Gin](https://wordpress.org/support/users/rawdolphe/)
 * Last activity: [2 years ago](https://wordpress.org/support/topic/query-loop-posts-in-gutenberg/#post-17761212)
 * Status: not resolved