Created
October 22, 2020 16:18
-
-
Save alanef/11b7a83559f88f18a3869ed8510d1ddc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Test Shortcode | |
| Plugin URI: https://fullworks.net | |
| Description: Test Shortcode Gutenberg content | |
| Version: 1.0 | |
| Author: alan | |
| Author URI: https://fullworks.net | |
| License: GPL2 | |
| */ | |
| if ( ! defined( 'WPINC' ) ) { | |
| die; | |
| } | |
| add_shortcode( 'test_display', function ( $atts ) { | |
| $a = shortcode_atts( array( | |
| 'id' => 0, | |
| ), $atts ); | |
| $return = ''; | |
| $blocks = parse_blocks( get_the_content( null, false, $a['id'] ) ); | |
| foreach ( $blocks as $block ) { | |
| $return .= apply_filters( 'the_content', render_block( $block ) ); | |
| } | |
| return $return; | |
| } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment