Title: Shortcodes and Processing Dynamic Data
Last modified: August 14, 2023

---

# Shortcodes and Processing Dynamic Data

 *  Resolved [Gerson L.](https://wordpress.org/support/users/gslweb/)
 * (@gslweb)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/)
 * I have 2 questions:
    1. Does the query loop block process shortcodes? I created a query loop to display
       a custom post type and inserted a shortcode in it but it doesn’t display the
       shortcode value. I know it’s working because I use it in the single post template
       and it displays it just fine, but not inside a query loop.
    2. Is there a filter I can use to modify the date format that’s fetched using dynamic
       data? It’s set by another plugin (not ACF) and it’s only saved using Y-m-d but
       I want to display it using F d, Y format. I initially thought of using a shortcode
       but no shortcodes seem to be processed inside the query loop. What would you
       suggest is the best way to modify the date format in this scenario?
 * Thanks!

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

 *  [fernandoazarcon2](https://wordpress.org/support/users/fernandoazarcon2/)
 * (@fernandoazarcon2)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/#post-16970029)
 * Hi [@gslweb](https://wordpress.org/support/users/gslweb/),
    1. Inherently, shortcodes work on Query Loops. What doesn’t work are functions 
       like get_the_ID(). This is a WordPress core issue though. You’ll experience 
       the same thing using the WordPress Query Loop Block. What you can use is a filter
       called render_block.
    2. There’s a generateblocks_dynamic_content_output filter you can use. You can 
       find the filter [here](https://github.com/tomusborne/generateblocks/blob/94e2ccd752c8334645d2d0434bcaf6e4f8dc1163/includes/class-dynamic-content.php#L133).
 *  Thread Starter [Gerson L.](https://wordpress.org/support/users/gslweb/)
 * (@gslweb)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/#post-16987919)
 * Would you be able to provide simple examples on how to use each of these?
 *  [fernandoazarcon2](https://wordpress.org/support/users/fernandoazarcon2/)
 * (@fernandoazarcon2)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/#post-16987950)
 * Here’s a sample code for a Headline Block with class **convert-to-fdy**
 *     ```wp-block-code
       add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){
       	if ( ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'convert-to-fdy' ) !== false ) {
       		$timestamp = strtotime($content);
       		$my_date = sprintf(
       		'<time datetime="%1$s">%2$s</time>',
       		date('c', $timestamp),
       		date('l F d, Y', $timestamp) );
       		return $my_date;
       	}
       	return $content;
       }, 10, 3);
       ```
   
 *  Thread Starter [Gerson L.](https://wordpress.org/support/users/gslweb/)
 * (@gslweb)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/#post-16988676)
 * Thanks! In case anyone needs it, here’s what I was able to come up with for #
   1:
 *     ```wp-block-code
       add_filter( 'render_block', function( $block_content, $block ) {
           if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'user-class-here' ) !== false ) {
       		$hosts = get_field('acf_user_field_id');
               if( $hosts ) {
                   $hosts_list = '<p>';
                   foreach( $hosts as $host ) {
                       $hosts_list .= $host['display_name'];
                   }
                   $hosts_list .= '</p>';
                   $block_content .= $hosts_list;
               }
   
           }
   
           return $block_content;
       }, 10, 2 );
       ```
   
 *  Plugin Support [David](https://wordpress.org/support/users/diggeddy/)
 * (@diggeddy)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/#post-16988811)
 * Hi there,
 * you may want to consider the `render_block_{$this->name}` hook:
 * [https://developer.wordpress.org/reference/hooks/render_block_this-name/](https://developer.wordpress.org/reference/hooks/render_block_this-name/)
 * it will limit your callback to just the specified block, instead of every block.
 *  [fernandoazarcon2](https://wordpress.org/support/users/fernandoazarcon2/)
 * (@fernandoazarcon2)
 * [2 years, 8 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/#post-17052258)
 * Hi there! We haven’t heard back from you for a while now so we’re going to go
   ahead and set this topic as resolved. Feel free to open a new topic if you need
   assistance with anything else.

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

The topic ‘Shortcodes and Processing Dynamic Data’ is closed to new replies.

 * ![](https://ps.w.org/generateblocks/assets/icon.svg?rev=3239461)
 * [GenerateBlocks](https://wordpress.org/plugins/generateblocks/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/generateblocks/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/generateblocks/)
 * [Active Topics](https://wordpress.org/support/plugin/generateblocks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/generateblocks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/generateblocks/reviews/)

## Tags

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

 * 6 replies
 * 3 participants
 * Last reply from: [fernandoazarcon2](https://wordpress.org/support/users/fernandoazarcon2/)
 * Last activity: [2 years, 8 months ago](https://wordpress.org/support/topic/shortcodes-and-processing-dynamic-data/#post-17052258)
 * Status: resolved