Skip to content

Instantly share code, notes, and snippets.

@indikatordesign
Last active March 15, 2018 19:34
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 indikatordesign/433385b4ad7be667e3537f7e4d430fe6 to your computer and use it in GitHub Desktop.
Save indikatordesign/433385b4ad7be667e3537f7e4d430fe6 to your computer and use it in GitHub Desktop.
[Divi Layout Shortcode]
<?php
// Add layouts to the Divi library and get the ID from the corresponding URL
// To get your results, you can add a shortcode to text fields as follows: [divi-layout id="7"]
add_shortcode( 'divi-layout', function( $atts )
{
$atts = shortcode_atts( [ 'id' => '', ], $atts );
if ( ! $atts['id'] || ! $p = get_post( (int) $atts['id'] ) )
return false;
return ( ET_BUILDER_LAYOUT_POST_TYPE == $p->post_type ) ? do_shortcode( $p->post_content ) : false;
}); // end add_shortcode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment