Title: Shortcodes Not Rendering In Patterns
Last modified: May 31, 2024

---

# Shortcodes Not Rendering In Patterns

 *  Resolved [kingchris](https://wordpress.org/support/users/kingchris/)
 * (@kingchris)
 * [2 years ago](https://wordpress.org/support/topic/shortcodes-not-rendering-in-patterns/)
 * Hi,
 * Are shortcodes not supported in patterns (synced or unsynced)? I created a button
   pattern that uses an ACF shortcode for the button text; however, it won’t render
   the shortcode on the front end. Any help is greatly appreciated! Thanks!

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

 *  [sbser123](https://wordpress.org/support/users/sbser123/)
 * (@sbser123)
 * [2 years ago](https://wordpress.org/support/topic/shortcodes-not-rendering-in-patterns/#post-17795011)
 * Yes, shortcodes are supported in WordPress patterns. However, the issue you’re
   experiencing with the ACF shortcode not rendering in your button pattern might
   be due to the fact that the pattern is not properly parsing the shortcode.
 *     ```wp-block-code
       <?php echo do_shortcode('[acf field="button_text"]'); ?>
       ```
   
 * or You can use this
 *     ```wp-block-code
       $button_text_shortcode = get_field('your_acf_field_for_button_shortcode');
       echo do_shortcode($button_text_shortcode);
       ```
   
 *  Thread Starter [kingchris](https://wordpress.org/support/users/kingchris/)
 * (@kingchris)
 * [2 years ago](https://wordpress.org/support/topic/shortcodes-not-rendering-in-patterns/#post-17795053)
 * Thanks [@sbser123](https://wordpress.org/support/users/sbser123/)!
 * I was able to get them to render with the following:
 *     ```wp-block-code
       function render_acf_shortcodes_in_blocks( $block_content, $block ) {
           if ( has_shortcode( $block_content, 'acf' ) || has_shortcode( $block_content, 'acf_field' ) ) {
               $block_content = do_shortcode( $block_content );
           }
           return $block_content;
       }
       add_filter( 'render_block', 'render_acf_shortcodes_in_blocks', 10, 2 );
       ```
   
 *  [jeysonkool](https://wordpress.org/support/users/jeysonkool/)
 * (@jeysonkool)
 * [1 year, 8 months ago](https://wordpress.org/support/topic/shortcodes-not-rendering-in-patterns/#post-18064289)
 * Hi [@kingchris](https://wordpress.org/support/users/kingchris/)!
 * In which php file should I put the code for the shortcodes to work in the patterns?
 * function render_acf_shortcodes_in_blocks( $block_content, $block ) { if ( has_shortcode(
   $block_content, ‘acf’ ) || has_shortcode( $block_content, ‘acf_field’ ) ) { $
   block_content = do_shortcode( $block_content ); } return $block_content; } add_filter(‘
   render_block’, ‘render_acf_shortcodes_in_blocks’, 10, 2 );

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

The topic ‘Shortcodes Not Rendering In Patterns’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 3 replies
 * 3 participants
 * Last reply from: [jeysonkool](https://wordpress.org/support/users/jeysonkool/)
 * Last activity: [1 year, 8 months ago](https://wordpress.org/support/topic/shortcodes-not-rendering-in-patterns/#post-18064289)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
