Last active
May 23, 2019 08:05
-
-
Save wplit/e79767544d0520eeb6dd1d9aead8232e to your computer and use it in GitHub Desktop.
Shortcode to allow inserting reusable Gutenberg block into Oxygen template
This file contains 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
add_shortcode('wp_oxy_reusable_block', 'lit_reusable_block_sc'); | |
/** | |
* Add a shortcode to allow resuable blocks, that are created in WP editor, to be inserted in Oxygen templates using their IDs | |
* | |
* Sample usage: [wp_oxy_reusable_block id='2543'] | |
*/ | |
function lit_reusable_block_sc( $atts ) { | |
$attributes = shortcode_atts( | |
array( | |
'id' => null | |
), $atts ); | |
$output = do_blocks( get_the_content('', '', get_post($attributes['id']) ) ); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment