Skip to content

Instantly share code, notes, and snippets.

@wplit
Last active May 23, 2019 08:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wplit/e79767544d0520eeb6dd1d9aead8232e to your computer and use it in GitHub Desktop.
Save wplit/e79767544d0520eeb6dd1d9aead8232e to your computer and use it in GitHub Desktop.
Shortcode to allow inserting reusable Gutenberg block into Oxygen template
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